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

Complexity

Total Complexity 5
Complexity/F 1.67

Size

Lines of Code 35
Function Count 3

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 20
mnd 2
bc 2
fnc 3
dl 0
loc 35
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('uuid');
4
5
suite('Rules: uuid');
6
7
const valid = [
8
    'b69f3671-01eb-4802-88f5-0bf567a9522c',
9
    '497680db-4963-488f-82ee-3ec0e734a7b6'
10
];
11
12
test('Positive: uuid', function () {
13
    for (const uuid of valid) {
14
        tester.positive(uuid, uuid);
15
    }
16
});
17
18
test('Positive: empty value', function () {
19
    tester.positive(null, null);
20
    tester.positive(undefined, undefined);
21
});
22
23
const invalid = [
24
    '00000000000000000000',
25
    'b4f32bd7-581c-5621-a698-33fa4d9fc14b' // v5
26
];
27
28
test('Negative: bad formats', function () {
29
    tester.negative(true, 'NOT_STRING', 'The value is not a string');
30
    tester.negative([ '[email protected]' ], 'NOT_STRING', 'The value is not a string');
31
32
    for (const uuid of invalid) {
33
        tester.negative(uuid, 'NOT_UUID', 'The value is not a valid UUID v4');
34
    }
35
});
36