tests/rules/path.test.js   A
last analyzed

Complexity

Total Complexity 3
Complexity/F 1

Size

Lines of Code 25
Function Count 3

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

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