Total Complexity | 3 |
Complexity/F | 1 |
Lines of Code | 23 |
Function Count | 3 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | // import { URL } from 'url'; |
||
2 | import { RuleTester } from '../utils'; |
||
3 | |||
4 | const tester = new RuleTester('hostname'); |
||
5 | |||
6 | suite('Rules: hostname'); |
||
7 | |||
8 | test('Positive: hostname', function () { |
||
9 | tester.positive('localhost', 'localhost'); |
||
10 | tester.positive('example.org', 'example.org'); |
||
11 | tester.positive('redis-849305.c940.eu-central-1-1.ec2.cloud.redislabs.com', 'redis-849305.c940.eu-central-1-1.ec2.cloud.redislabs.com'); |
||
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('http://localhost', 'INVALID_HOST', 'Host not valid'); |
||
22 | tester.negative('local host', 'INVALID_HOST', 'Host not valid'); |
||
23 | tester.negative('localhost:5040', 'INVALID_HOST', 'Host not valid'); |
||
24 | }); |
||
25 |