|
| 1 | +import { describe, expect, test } from "vitest"; |
| 2 | +import checkPassword from "."; |
| 3 | + |
| 4 | +describe("checkPassword 유틸 함수 테스트", () => { |
| 5 | + describe("유효한 비밀번호에 대해 true를 반환해야 합니다.", () => { |
| 6 | + test("기본 상태는 아무 옵션도 설정되어있지 않기 때문에 true를 반환해야 합니다.", () => { |
| 7 | + expect(checkPassword("Valid123!", {})).toBe(true); |
| 8 | + }); |
| 9 | + test("특수 문자가 필요한 경우 true를 반환해야 합니다.", () => { |
| 10 | + expect(checkPassword("vsdvdsvsdvs1!", { requireSpecialChar: true })).toBe( |
| 11 | + true |
| 12 | + ); |
| 13 | + }); |
| 14 | + test("대문자가 필요한 경우 true를 반환해야 합니다.", () => { |
| 15 | + expect(checkPassword("Vsdvd", { requireUppercase: true })).toBe(true); |
| 16 | + }); |
| 17 | + test("최소 3자, 최대 5자의 길이를 가져야 하는 경우 true를 반환해야 합니다.", () => { |
| 18 | + expect(checkPassword("Vsd", { minLength: 3, maxLength: 5 })).toBe(true); |
| 19 | + }); |
| 20 | + }); |
| 21 | + |
| 22 | + describe("유효하지 않은 비밀번호에 대해 false를 반환해야 합니다.", () => { |
| 23 | + test("길이가 유효하지 않은 경우 false를 반환해야 합니다.", () => { |
| 24 | + expect(checkPassword("invalid", { minLength: 3, maxLength: 5 })).toBe( |
| 25 | + false |
| 26 | + ); |
| 27 | + }); |
| 28 | + test("특수 문자가 없는 경우 false를 반환해야 합니다.", () => { |
| 29 | + expect(checkPassword("dffadsfas", { requireSpecialChar: true })).toBe( |
| 30 | + false |
| 31 | + ); |
| 32 | + }); |
| 33 | + }); |
| 34 | +}); |
0 commit comments