Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
adding tests for false cases
  • Loading branch information
TzeMingHo committed Oct 7, 2025
commit 791b52a93affe1214f8362e6184592c64699d6a4
26 changes: 26 additions & 0 deletions Sprint-3/3-stretch/password-validator.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,30 @@ describe("passwordValidator", () => {
test("return true for passwords that are not in the previous passwords array", () => {
expect(isValidPassword(validPassword)).toBe(true);
});

// tests for false cases

test("returns false for passwords with less than 5 characters", () => {
expect(isValidPassword("1234")).toBe(false);
});

test("returns false for passwords without an uppercase letter", () => {
expect(isValidPassword("123ab*")).toBe(false);
});

test("returns false for passwords without a lowercase letter", () => {
expect(isValidPassword("123AB*")).toBe(false);
});

test("returns false for passwords without a number", () => {
expect(isValidPassword("abAB*")).toBe(false);
});

test("returns false for passwords without a non-alphanumeric symbol", () => {
expect(isValidPassword("123Abc")).toBe(false);
});

test("returns false for passwords that are in the previous passwords array", () => {
expect(isValidPassword("123Ab!")).toBe(false);
});
});