tests/rules/email.test.js   A
last analyzed

Complexity

Total Complexity 5
Complexity/F 1.67

Size

Lines of Code 42
Function Count 3

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 24
mnd 2
bc 2
fnc 3
dl 0
loc 42
bpm 0.6666
cpm 1.6666
noi 0
c 0
b 0
f 0
rs 10
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