Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solution #109

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
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
40 changes: 35 additions & 5 deletions src/checkPassword.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,47 @@
describe(`Function 'checkPassword':`, () => {
const checkPassword = require('./checkPassword');

it(`should be declared`, () => {
expect(checkPassword).toBeInstanceOf(Function);
it(`should return a boolean`, () => {
expect(typeof checkPassword('Password1!')).toBe('boolean');
});

it(`should return boolean`, () => {
it(`should return true for a valid password with 8 characters`, () => {
expect(checkPassword('Pass1@rd')).toBe(true);
});

it(`should return 'false' for a password with 7 characters`, () => {
expect(checkPassword('Pass1!')).toBe(false);
});

it(`should return 'true' for a valid password with 9 characters`, () => {
expect(checkPassword('Passw0rd!')).toBe(true);
});

it(`should return 'true' for the valid password with 8 characters`, () => {
it(`should return 'true' for a valid password with 15 characters`, () => {
expect(checkPassword('Passw0rd12345!')).toBe(true);
});

it(`should return 'true' for a valid password with 16 characters `, () => {
expect(checkPassword('Passw0rd123456!')).toBe(true);
});

// write more tests here
it(`should return 'false' for a password with 17 characters`, () => {
expect(checkPassword('Passw0rd1234567!!')).toBe(false);
});

it(`should return false for a password without uppercase letter`, () => {
expect(checkPassword('password1!')).toBe(false);
});

it(`should return false for a password without a digit`, () => {
expect(checkPassword('Password!')).toBe(false);
});

it(`should return false for a password without a special character`, () => {
expect(checkPassword('Password1')).toBe(false);
});

it(`should return false for a password with non-Latin characters`, () => {
expect(checkPassword('Passw0rd1@Д')).toBe(false);
});
});