-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspec.js
50 lines (38 loc) · 1.29 KB
/
spec.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
const {
getIp,
hitIp,
checkReachablity,
netCheck
} = require('./index');
jest.setTimeout(10000);
describe('Ping based NetCheck', () => {
test('test getIp method without parameters', () => {
expect(getIp).toThrowError();
});
test('test getIp method with valid parameters', async () => {
expect(await getIp('google.com', 2000)).toBeTruthy();
});
test('test getIp method with impossible timeout', () => {
expect(getIp.bind('google.com', 0)).toThrowError();
});
test('test hitIp method without parameters', () => {
expect(hitIp).toThrowError();
});
test('test hitIp method with valid parameters', async ()=> {
expect(await hitIp('172.217.18.196', 2000)).toBeTruthy();
});
test('test checkReachability method without parameters', () => {
expect(checkReachablity).rejects;
});
test('test checkReachability method with valid parameters', async () => {
expect(await checkReachablity('google.com', 2000)).toBeTruthy();
});
test('test netCheck method', async () => {
expect(await netCheck()).toBeTruthy();
});
test('test netCheck method with impossible timeout', async () => {
expect(await netCheck({
timeout: 1
})).toBeFalsy();
});
});