Total Complexity | 5 |
Complexity/F | 1.67 |
Lines of Code | 42 |
Function Count | 3 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import { RuleTester } from '../utils'; |
||
2 | |||
3 | const tester = new RuleTester('email'); |
||
4 | |||
5 | suite('Rules: email'); |
||
6 | |||
7 | const valid = [ |
||
8 | '[email protected]', |
||
9 | // eslint-disable-next-line no-secrets/no-secrets |
||
10 | '[email protected]', |
||
11 | '"dasdsd@dkslfksd"@kfdfkds.dlkfdf', |
||
12 | '[email protected]' |
||
13 | ]; |
||
14 | |||
15 | test('Positive: email', function () { |
||
16 | for (const email of valid) { |
||
17 | tester.positive(email, email); |
||
18 | } |
||
19 | }); |
||
20 | |||
21 | test('Positive: empty value', function () { |
||
22 | tester.positive(null, null); |
||
23 | tester.positive(undefined, undefined); |
||
24 | }); |
||
25 | |||
26 | |||
27 | const invalid = [ |
||
28 | '[email protected]', |
||
29 | 'zidalbak@pabwi[zi].hk', |
||
30 | 'cowo"@ibaceti.re', |
||
31 | 's[[email protected]' |
||
32 | // '[email protected]' |
||
33 | ]; |
||
34 | |||
35 | test('Negative: bad formats', function () { |
||
36 | tester.negative(true, 'NOT_STRING', 'The value is not a string'); |
||
37 | tester.negative([ '[email protected]' ], 'NOT_STRING', 'The value is not a string'); |
||
38 | |||
39 | for (const email of invalid) { |
||
40 | tester.negative(email, 'WRONG_EMAIL', 'The value is not a valid rfc5322 email format'); |
||
41 | } |
||
42 | }); |
||
43 |