-
Notifications
You must be signed in to change notification settings - Fork 155
Expand file tree
/
Copy pathcheckPassword.test.js
More file actions
60 lines (47 loc) · 1.75 KB
/
checkPassword.test.js
File metadata and controls
60 lines (47 loc) · 1.75 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';
const checkPassword = require('./checkPassword');
describe(`Function 'checkPassword':`, () => {
it(`should be declared`, () => {
expect(checkPassword).toBeInstanceOf(Function);
});
it(`should return a boolean`, () => {
const result = checkPassword('Password1!');
expect(typeof result).toBe('boolean');
});
it(`should return true for valid password with 8 characters`, () => {
const result = checkPassword('Abcdef1!');
expect(result).toBe(true);
});
it(`should return true for valid password with 16 characters`, () => {
const result = checkPassword('Abcdefgh1234!XYZ');
expect(result).toBe(true);
});
it(`should return false for password shorter than 8 characters`, () => {
const result = checkPassword('Ab1!');
expect(result).toBe(false);
});
it(`should return false for password longer than 16 characters`, () => {
const result = checkPassword('Abcdefghijklmnop1!');
expect(result).toBe(false);
});
it(`should return false for password without uppercase letter`, () => {
const result = checkPassword('abcdef1!');
expect(result).toBe(false);
});
it(`should return false for password without digit`, () => {
const result = checkPassword('Abcdefgh!');
expect(result).toBe(false);
});
it(`should return false for password without special character`, () => {
const result = checkPassword('Abcdefg1');
expect(result).toBe(false);
});
it(`should return false for password with non-Latin characters`, () => {
const result = checkPassword('Пароль1!');
expect(result).toBe(false);
});
it(`should return true for password with mix of allowed symbols`, () => {
const result = checkPassword('XyZ123@#');
expect(result).toBe(true);
});
});