-
Notifications
You must be signed in to change notification settings - Fork 4
/
utils.test.ts
55 lines (45 loc) · 1015 Bytes
/
utils.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
const utils = require('./utils.ts');
test('hostfile no matches', () => {
const connectors = [
{
label: 'test',
},
];
expect(utils.connectorsToHostFile(connectors)).toBe('');
});
test('hostfile basic', () => {
const connectors = [
{
label: 'test',
matches: ['*://*.example.com/*'],
},
];
expect(utils.connectorsToHostFile(connectors)).toBe('# test\nexample.com');
});
test('hostfile with tld', () => {
const connectors = [
{
label: 'test',
matches: ['*://example.*/*'],
},
];
expect(utils.connectorsToHostFile(connectors)).toBe('# test\nexample.tld');
});
test('hostfile with wildcard domain', () => {
const connectors = [
{
label: 'test',
matches: ['*://*nts.live/'],
},
];
expect(utils.connectorsToHostFile(connectors)).toBe('');
});
test('hostfile basic with trailing slash', () => {
const connectors = [
{
label: 'test',
matches: ['*://*.example.com/'],
},
];
expect(utils.connectorsToHostFile(connectors)).toBe('# test\nexample.com');
});