-
Notifications
You must be signed in to change notification settings - Fork 155
Expand file tree
/
Copy pathcheckPassword.test.js
More file actions
59 lines (47 loc) · 1.74 KB
/
checkPassword.test.js
File metadata and controls
59 lines (47 loc) · 1.74 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
'use strict';
describe(`Function 'checkPassword':`, () => {
const checkPassword = require('./checkPassword');
it(`should be declared`, () => {
expect(checkPassword).toBeInstanceOf(Function);
});
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('Test1!ok')).toBe(true);
});
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);
});
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);
});
});