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

Check Password #102

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
@@ -1,19 +1,49 @@
'use strict';

describe(`Function 'checkPassword':`, () => {
describe('Function checkPassword:', () => {
const checkPassword = require('./checkPassword');

it(`should be declared`, () => {
it('should be declared', () => {
expect(checkPassword).toBeInstanceOf(Function);
});

it(`should return boolean`, () => {
it('should return boolean', () => {
expect(typeof checkPassword('Testpass#1')).toBe('boolean');
});

it('should return true for valid 8-character password', () => {
expect(checkPassword('Passw#1a')).toBeTruthy();
});

it('should return true for valid 16-character password', () => {
expect(checkPassword('Testpass#1Testpa')).toBeTruthy();
});

it(`should return 'true' for the valid password with 8 characters`, () => {
it('should return true for valid 12-character password', () => {
expect(checkPassword('Testpass#1qw')).toBeTruthy();
});

it('should return false for 7-character password', () => {
expect(checkPassword('Testp#1')).toBeFalsy();
});

// write more tests here
it('should return false for 17-character password', () => {
expect(checkPassword('Testpass#1Testpas')).toBeFalsy();
});

it('should return false for password without digit', () => {
expect(checkPassword('TestPASSword@@')).toBeFalsy();
});

it('should return false for password without symbol', () => {
expect(checkPassword('TestpassWord1')).toBeFalsy();
});

it('should return false for password without uppercase', () => {
expect(checkPassword('testpass#1testpas')).toBeFalsy();
});

it('should return true for password with one uppercase letter', () => {
expect(checkPassword('1234567Fs@')).toBeTruthy();
});
});