Total Complexity | 3 |
Complexity/F | 1 |
Lines of Code | 25 |
Function Count | 3 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import path from 'path'; |
||
2 | import { RuleTester } from '../utils'; |
||
3 | |||
4 | const tester = new RuleTester('path'); |
||
5 | |||
6 | suite('Rules: path'); |
||
7 | |||
8 | test('Positive: path', function () { |
||
9 | tester.positive('file.js', 'file.js'); |
||
10 | tester.positive('/tmp//file.js', path.normalize('/tmp/file.js')); |
||
11 | tester.positive('./file.js', 'file.js'); |
||
12 | tester.positive(' /home/user/../file.js ', path.normalize('/home/file.js')); |
||
13 | }); |
||
14 | |||
15 | test('Positive: empty value', function () { |
||
16 | tester.positive(null, null); |
||
17 | tester.positive(undefined, undefined); |
||
18 | }); |
||
19 | |||
20 | test('Negative: bad formats', function () { |
||
21 | tester.negative({ object: 1 }, 'NOT_STRING', 'The value is not a string'); |
||
22 | tester.negative('file.\u0000\u0000\u0000js', 'ILLEGAL_PATH', 'string can not be used as legal file path'); |
||
23 | tester.negative('file.*js', 'ILLEGAL_PATH', 'string can not be used as legal file path'); |
||
24 | tester.negative(`/subdir/${String.fromCodePoint(10)}smth/file.js`, 'ILLEGAL_PATH', 'string can not be used as legal file path'); |
||
25 | }); |
||
26 |