Skip to content
Closed
19 changes: 13 additions & 6 deletions Sprint-3/3-stretch/password-validator.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ test("password has at least 5 characters", () => {
// passsword has at least one uppercase letter
test("password has at least one uppercase letter", () => {

const password = "1234a";
const password = "abcd!1";
const result = isValidPassword(password);
expect(result).toEqual(false);
}
Expand All @@ -37,7 +37,7 @@ test("password has at least one uppercase letter", () => {
// password has at least one lowercase letter
test("password has at least one lowercase letter", () => {

const password = "1234A";
const password = "ABCD!1";
const result = isValidPassword(password);
expect(result).toEqual(false);
}
Expand All @@ -46,7 +46,7 @@ test("password has at least one lowercase letter", () => {
// password has at least one number
test("password has at least one number", () => {

const password = "abcdA";
const password = "Abcd!@";
const result = isValidPassword(password);
expect(result).toEqual(false);
}
Expand All @@ -55,7 +55,7 @@ test("password has at least one number", () => {
// password has at least one symbol:
test("password has at least one symbol: (!, #, $, %, ., *, &)", () => {

const password = "abcdA1";
const password = "abcd12";
const result = isValidPassword(password);
expect(result).toEqual(false);
}
Comment on lines 56 to 61
Copy link
Copy Markdown
Contributor

@cjyuan cjyuan Oct 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are two possible reasons the test could pass;
the new password does not contain any uppercase letter (in addition to not containing any symbol).

Comment on lines 56 to 61
Copy link
Copy Markdown
Contributor

@cjyuan cjyuan Oct 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something about this test is still not quite right. Can you fix the issue?

Expand All @@ -64,9 +64,16 @@ test("password has at least one symbol: (!, #, $, %, ., *, &)", () => {
// password must not be any previous password in the passwords array.
test("password must not be any previous password in the passwords array.", () => {

const password = "abcde1!";
const password = "abcd!1";
const result = isValidPassword(password);
expect(result).toEqual(false);
}
);

// password is valid when all requirements are met
test ("password is valid when it meets all requirements",() =>{

const password = "Abcd!2";
const result = isValidPassword(password);
expect(result).toEqual(true);
}
);