Total Complexity | 5 |
Complexity/F | 1.67 |
Lines of Code | 35 |
Function Count | 3 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
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 |