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

Complexity

Total Complexity 3
Complexity/F 1

Size

Lines of Code 23
Function Count 3

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 15
mnd 0
bc 0
fnc 3
dl 0
loc 23
bpm 0
cpm 1
noi 0
c 0
b 0
f 0
rs 10
1
import { URL } from 'url';
2
import { RuleTester } from '../utils';
3
4
const tester = new RuleTester('url');
5
6
suite('Rules: url');
7
8
test('Positive: url', function () {
9
    tester.positive('https://ec.ne/capih', new URL('https://ec.ne/capih'));
10
    tester.positive('http://localhost:60606',  new URL('http://localhost:60606'));
11
    tester.positive('https://測試',  new URL('https://測試'));
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({ object: 1 }, 'NOT_STRING', 'The value is not a string');
21
    tester.negative('google', 'INVALID_URL', 'The value is invalid URL');
22
    tester.negative('http://localhost:234543580', 'INVALID_URL', 'The value is invalid URL');
23
});
24