1
0
Fork 0
mirror of https://github.com/mealie-recipes/mealie.git synced 2025-08-05 05:25:26 +02:00

fix: eslint errors and failing tests (#2078)

* fix eslint errors

* fix failing tests
This commit is contained in:
Hayden 2023-01-29 13:01:41 -09:00 committed by GitHub
parent 7c766af848
commit 5dc253799d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 35 additions and 29 deletions

View file

@ -1,20 +1,16 @@
import { ref } from "@nuxtjs/composition-api";
import { describe, expect, test } from "vitest";
import { usePasswordStrength } from "./use-passwords";
import { stubI18n } from "~/tests/utils";
// test("test usePasswordField", () => {
// const { inputType, togglePasswordShow, passwordIcon } = usePasswordField();
// expect(inputType.value).toBe("password");
// expect(passwordIcon.value).toBe("mdi-eye");
// togglePasswordShow();
// expect(inputType.value).toBe("text");
// expect(passwordIcon.value).toBe("mdi-eye-off");
// });
describe("test usePasswordStrength", () => {
test("weak password", () => {
const password = ref("123456");
const { score, strength, color } = usePasswordStrength(password);
const pw = ref("123456");
const result = usePasswordStrength(pw, stubI18n());
const { score, strength, color } = result
expect(score.value).toBeGreaterThan(0);
expect(score.value).toBeLessThan(40);
expect(strength.value).toBe("Weak");
@ -23,7 +19,7 @@ describe("test usePasswordStrength", () => {
test("very strong password", () => {
const password = ref("My~Secret~Not~So~Secret?123");
const { score, strength, color } = usePasswordStrength(password);
const { score, strength, color } = usePasswordStrength(password, stubI18n());
expect(score.value).toBeGreaterThan(90);
expect(score.value).toBe(100);
expect(strength.value).toBe("Very Strong");

View file

@ -1,9 +1,9 @@
import { computed, Ref, ref, useContext } from "@nuxtjs/composition-api";
import VueI18n from "vue-i18n";
import { scorePassword } from "~/lib/validators";
export function usePasswordField() {
const show = ref(false);
const { $globals } = useContext();
const passwordIcon = computed(() => {
@ -22,14 +22,8 @@ export function usePasswordField() {
};
}
export const usePasswordStrength = (password: Ref<string>) => {
const { i18n } = useContext();
const score = computed(() => {
return scorePassword(password.value);
});
export const usePasswordStrength = (password: Ref<string>, i18n: VueI18n) => {
const score = computed(() => scorePassword(password.value));
const strength = computed(() => {
if (score.value < 50) {
return i18n.tc("user.password-strength-values.weak");