Total Complexity | 5 |
Complexity/F | 1 |
Lines of Code | 32 |
Function Count | 5 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import { RuleTester } from '../utils'; |
||
2 | |||
3 | const tester = new RuleTester('date'); |
||
4 | |||
5 | suite('Rules: date'); |
||
6 | |||
7 | test('Positive: numbers', function () { |
||
8 | const d = new Date(); |
||
9 | |||
10 | tester.positive(+d, d); |
||
11 | }); |
||
12 | |||
13 | test('Positive: string', function () { |
||
14 | tester.positive('04 Dec 1995 00:12:00 GMT', new Date('1995-12-04T00:12:00.000Z')); |
||
15 | tester.positive('2022-10-20T19:33:38.118Z', new Date('2022-10-20T19:33:38.118Z')); |
||
16 | }); |
||
17 | |||
18 | test('Positive: empty value', function () { |
||
19 | tester.positive(null, null); |
||
20 | tester.positive(undefined, undefined); |
||
21 | }); |
||
22 | |||
23 | const txt = 'The value is not a valid date'; |
||
24 | |||
25 | test('Negative: numbers', function () { |
||
26 | tester.negative(Number.NaN, 'NOT_DATE', txt); |
||
27 | }); |
||
28 | |||
29 | test('Negative: bad formats', function () { |
||
30 | tester.negative({ object: 1 }, 'NOT_DATE', txt); |
||
31 | tester.negative('x', 'NOT_DATE', txt); |
||
32 | }); |
||
33 |