-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscripts.test.js
109 lines (108 loc) · 3.72 KB
/
scripts.test.js
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
const {
emailValidator,
passwordValidator,
passwordGenerator,
loginValidator,
polishPostCodeVerifier,
polishPostCodeModifier,
dutchPostCodeVerifier,
dutchPostCodeModifier} = require('./scripts');
describe("emailValidator checker", () => {
test('Correct email', () => {
expect(emailValidator('[email protected]')).toBeTruthy();
});
test('2*@ and more - Incorrect', () => {
expect(emailValidator('mojasuperfirma@@gmail.com')).toBeFalsy();
});
test('No domain extension - Incorrect', () => {
expect(emailValidator('mojasuperfirma@gmail')).toBeFalsy();
});
test('Space in email - Incorrect', () => {
expect(emailValidator('mojasuper [email protected]')).toBeFalsy();
});
});
describe("passwordValidator checker", () => {
test('Correct password', async () => {
expect(passwordValidator('yNaTccN*qnjOCZ34')).toBeTruthy();
});
test('Missing capital letter - Incorrect', async () => {
expect(passwordValidator('ynatccn*qnjacz34')).toBeFalsy();
});
test('Missing small letter - Incorrect', async () => {
expect(passwordValidator('YNATCCN*QNJOCZ34!')).toBeFalsy();
});
test('Missing numbers letter - Incorrect', async () => {
expect(passwordValidator('SuperLongPassword!')).toBeFalsy();
});
test('Missing special digit - Incorrect', async () => {
expect(passwordValidator('yNaTccNqnjOCZ34')).toBeFalsy();
});
test('Have spaces - Incorrect', async () => {
expect(passwordValidator('yNaTccN* qnjOCZ34')).toBeFalsy();
});
});
describe.skip("Password generator", () =>{
test('Pass passwordValidator', () => {
for(let i=0; i<50; i++){
expect(passwordValidator(passwordGenerator())).toBeTruthy();
}
});
});
describe("Login validator", () => {
test("Correct login", () => {
expect(loginValidator('mjfutera')).toBeTruthy();
});
test("To short - Incorrect", () => {
expect(loginValidator('mjfa')).toBeFalsy();
});
test("Spaces between - Incorrect", () => {
expect(loginValidator('mj futera')).toBeFalsy();
});
});
describe("polishPostCodeVerifier checker", () => {
test("33-100 to by truthy", () => {
expect(polishPostCodeVerifier('33-100')).toBeTruthy();
})
test("33100 to by truthy", () => {
expect(polishPostCodeVerifier('33100')).toBeTruthy();
})
test("33 100 to by falsy", () => {
expect(polishPostCodeVerifier('33 100')).toBeFalsy();
})
test("331000 to by falsy", () => {
expect(polishPostCodeVerifier('331000')).toBeFalsy();
})
})
describe("polishPostCodeModifier checker", () => {
test("33-100 -> 33-100", () => {
expect(polishPostCodeModifier('33-100')).toBe('33-100');
})
test("33100 -> 33-100", () => {
expect(polishPostCodeModifier('33100')).toBe('33-100');
})
})
describe("dutchPostCodeVerifier checker", () => {
test("2021EB to by truthy", () => {
expect(dutchPostCodeVerifier('2021EB')).toBeTruthy();
})
test("2021 EB to by truthy", () => {
expect(dutchPostCodeVerifier('2021 EB')).toBeTruthy();
})
test("20211eb to by falsy", () => {
expect(dutchPostCodeVerifier('20211eb')).toBeFalsy();
})
test("2021eeb to by falsy", () => {
expect(dutchPostCodeVerifier('2021eeb')).toBeFalsy();
})
test("2021 EB to by falsy", () => {
expect(dutchPostCodeVerifier('2021 EB')).toBeFalsy();
})
})
describe("dutchPostCodeModifier checker", () => {
test("2021eb -> 2021EB", () => {
expect(dutchPostCodeModifier('2021eb')).toBe('2021EB');
})
test("2021 eb -> 2021EB", () => {
expect(dutchPostCodeModifier('2021 eb')).toBe('2021EB');
})
})