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
44 changes: 42 additions & 2 deletions src/checkPassword.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,52 @@ describe(`Function 'checkPassword':`, () => {
});

it(`should return boolean`, () => {
expect(typeof checkPassword('Password1!')).toBe('boolean');
expect(typeof checkPassword('qwerty')).toBe('boolean');
});

it(`should return 'true' for the valid password
with all rules`, () => {
expect(checkPassword('Password1!')).toBe(true);
});

it(`should return 'true' for the valid password
with at least 8 characters`, () => {
expect(checkPassword('Password1!')).toBe(true);

Choose a reason for hiding this comment

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

This test is a good idea, but the password you're using ('Password1!') is 10 characters long, which doesn't specifically test the lower boundary. The task requirements state that you should test boundary conditions, including a valid password of exactly 8 characters. Please update this test with an 8-character password that meets all the other validity rules (e.g., 'Test1!ok').

});

it(`should return 'true' for the valid password with 8 characters`, () => {
it(`should return 'true' for the valid password
with max 16 characters`, () => {
expect(checkPassword('Password1!Passwo')).toBe(true);
});

it(`should return 'false' for the invalid password
with less than 8 characters`, () => {
expect(checkPassword('Passw1!')).toBe(false);
});

// write more tests here
it(`should return 'false' for the invalid password
with more than 16 characters`, () => {
expect(checkPassword('Password1!Password')).toBe(false);
});

it(`should return 'false' for the invalid password
without at least 1 digit`, () => {
expect(checkPassword('Str@ngks')).toBe(false);
});

it(`should return 'false' for the invalid password
without at least 1 special character`, () => {
expect(checkPassword('Qwerty123')).toBe(false);
});

it(`should return 'false' for the invalid password
without at least 1 uppercase letter`, () => {
expect(checkPassword('qwerty12@')).toBe(false);
});

it(`should return 'false' for the invalid password
without letters of the Latin alphabet `, () => {
expect(checkPassword('Пароль1!')).toBe(false);
});

Choose a reason for hiding this comment

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

This is a great set of tests! To make it complete, consider adding one more test case for a password that fails multiple validation rules at once, like 'qwerty', which is mentioned as an example in the task description.

});