Passed
Push — master ( cf63aa...7c7a6d )
by Dmytro
02:48
created

tests/rules/date.test.js   A

Complexity

Total Complexity 5
Complexity/F 1

Size

Lines of Code 32
Function Count 5

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 18
mnd 0
bc 0
fnc 5
dl 0
loc 32
rs 10
bpm 0
cpm 1
noi 0
c 0
b 0
f 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