-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
test.js
26 lines (21 loc) · 752 Bytes
/
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
import process from 'node:process';
import test from 'ava';
import isPortReachable from './index.js';
if (!('CI' in process.env)) {
test('ip', async t => {
t.true(await isPortReachable(80, {host: '142.250.199.46'})); // 142.250.199.46 === google.com
});
}
test('domain', async t => {
t.true(await isPortReachable(80, {host: 'google.com'}));
});
test('domain - alternative port', async t => {
t.false(await isPortReachable(8000, {host: 'google.com'}));
});
test('domain - with subdomain', async t => {
t.true(await isPortReachable(80, {host: 'newsletter.sindresorhus.com'}));
});
test('fail', async t => {
t.false(await isPortReachable(0, {host: 'localhost'}));
await t.throwsAsync(isPortReachable(80), {message: 'Specify a `host`'});
});