Total Complexity | 5 |
Complexity/F | 1.25 |
Lines of Code | 36 |
Function Count | 4 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import { RuleTester } from '../utils'; |
||
2 | |||
3 | const tester = new RuleTester('cron'); |
||
4 | |||
5 | suite('Rules: cron'); |
||
6 | |||
7 | const valid = [ |
||
8 | '0 4 8-14 * *', |
||
9 | '0 0 1,15 * 3', |
||
10 | '5 0 * 8 *', |
||
11 | '23 0-20/2 * * *', |
||
12 | '5-10 4 */3 * sun', |
||
13 | '0 0,5-12 1 */2 *' |
||
14 | ]; |
||
15 | |||
16 | test('Positive: cron', function () { |
||
17 | for (const cron of valid) { |
||
18 | tester.positive(cron, cron); |
||
19 | } |
||
20 | }); |
||
21 | |||
22 | test('Positive: empty value', function () { |
||
23 | tester.positive(null, null); |
||
24 | tester.positive(undefined, undefined); |
||
25 | }); |
||
26 | |||
27 | test('Negative: bad formats', function () { |
||
28 | tester.negative(true, 'NOT_STRING', 'The value is not a string'); |
||
29 | tester.negative([ '0', '4', '8-14', '*', '*' ], 'NOT_STRING', 'The value is not a string'); |
||
30 | }); |
||
31 | |||
32 | test('Negative: malformed cron', function () { |
||
33 | tester.negative('0 22 * 1-5', 'INVALID_CRON', 'The value can not be parsed as cron string'); |
||
34 | tester.negative('0 22 * * * *', 'INVALID_CRON', 'The value can not be parsed as cron string'); |
||
35 | tester.negative('5-10 4 */3 * SUNDAY', 'INVALID_CRON', 'The value can not be parsed as cron string'); |
||
36 | }); |
||
37 | |||
38 |