-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtest.js
62 lines (52 loc) · 1.26 KB
/
test.js
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
56
57
58
59
60
61
62
import test from 'ava';
import m from '.';
const v2 = [
'xmh57jrzrnw6insl.onion',
'facebookcorewwwi.onion',
'3g2upl4pq6kufc4m.onion',
'fncuwbiisyh6ak3i.onion'
];
const v3 = [
'vww6ybal4bd7szmgncyruucpgfkqahzddi37ktceo3ah7ngmcopnpyyd.onion',
'32zzibxmqi2ybxpqyggwwuwz7a3lbvtzoloti7cxoevyvijexvgsfeid.onion',
'ozmh2zkwx5cjuzopui64csb5ertcooi5vya6c2gm4e3vcvf2c2qvjiyd.onion',
'jamie3vkiwibfiwucd6vxijskbhpjdyajmzeor4mc4i7yopvpo4p7cyd.onion'
];
const onionsNot = [
'nikolaskama.me',
'0x281055afc982d96fab65b3a49cac8b878184cb16',
'nikolaskam@gmail.com foo',
'absdefghijklmn[IPv6:2001:db8::2]',
'https://abc.xyz'
];
test('Exact onion links', t => {
for (const x of v2) {
t.true(m({exact: true}).test(x));
}
for (const x of v3) {
t.true(m({exact: true}).test(x));
}
});
test('Non-exact onion links', t => {
for (const x of v2) {
t.is((m().exec(`foo ${x} bar`) || [])[0], x);
}
for (const x of v3) {
t.is((m().exec(`foo ${x} bar`) || [])[0], x);
}
});
test('Non-onion links', t => {
for (const x of onionsNot) {
t.false(m({exact: true}).test(x));
}
});
test('v2 onion links', t => {
for (const x of v2) {
t.true(m.v2({exact: true}).test(x));
}
});
test('v3 onion links', t => {
for (const x of v3) {
t.true(m.v3({exact: true}).test(x));
}
});