-
Notifications
You must be signed in to change notification settings - Fork 155
Expand file tree
/
Copy pathcheckPassword.test.js
More file actions
63 lines (47 loc) · 1.92 KB
/
checkPassword.test.js
File metadata and controls
63 lines (47 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
'use strict';
describe(`Function 'checkPassword':`, () => {
const checkPassword = require('./checkPassword');
it(`should be declared`, () => {
expect(checkPassword).toBeInstanceOf(Function);
});
it(`should return boolean`, () => {
const result = checkPassword('Password1!');
expect(typeof result).toBe('boolean');
});
it(`should return true for a valid password (example: 'Password1!')`, () => {
expect(checkPassword('Password1!')).toBe(true);
});
it(`should return false for password with less than 8 characters`, () => {
expect(checkPassword('P@ss1')).toBe(false);
});
it(`should return false for password with more than 16 characters`, () => {
expect(checkPassword('Password12345678!')).toBe(false);
});
it(`should return false for password without uppercase letter`, () => {
expect(checkPassword('password1!')).toBe(false);
});
it(`should return false for password without digit`, () => {
expect(checkPassword('Password!')).toBe(false);
});
it(`should return false for password without special character`, () => {
expect(checkPassword('Password1')).toBe(false);
});
it(`should return false for password containing Cyrillic letters`, () => {
expect(checkPassword('Пароль1!')).toBe(false);
});
it(`should return false for password with only lowercase letters`, () => {
expect(checkPassword('qwertyui')).toBe(false);
});
it(`should return false for password with only uppercase letters`, () => {
expect(checkPassword('PASSWORD1!')).toBe(false);
});
it(`should return true for valid password of exactly 8 characters`, () => {
expect(checkPassword('Passw1!A')).toBe(true);
});
it(`should return true for valid password of exactly 16 characters`, () => {
expect(checkPassword('ValidPassw1!Word')).toBe(true);
});
it(`should return false for password with spaces`, () => {
expect(checkPassword('Pass word1!')).toBe(false);
});
});