Total Complexity | 3 |
Complexity/F | 1 |
Lines of Code | 24 |
Function Count | 3 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import { RuleTester } from '../utils'; |
||
2 | |||
3 | const tester = new RuleTester('time_unit'); |
||
4 | |||
5 | suite('Rules: time_unit'); |
||
6 | |||
7 | test('Positive: time_unit', function () { |
||
8 | tester.positive('1s', 1000); |
||
9 | tester.positive(' -1000', -1000); |
||
10 | tester.positive(0, 0); |
||
11 | tester.positive(' -2 hours ', -2 * 60 * 60 * 1000); |
||
12 | }); |
||
13 | |||
14 | test('Positive: empty value', function () { |
||
15 | tester.positive(null, null); |
||
16 | tester.positive(undefined, undefined); |
||
17 | }); |
||
18 | |||
19 | test('Negative: bad formats', function () { |
||
20 | tester.negative(true, 'WRONG_FORMAT', 'Format not supported'); |
||
21 | |||
22 | tester.negative('very long time', 'WRONG_TIME_UNIT', 'The value can not be parsed as time unit'); |
||
23 | tester.negative('78 days/h', 'WRONG_TIME_UNIT', 'The value can not be parsed as time unit'); |
||
24 | }); |
||
25 |