-
-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathtest.js
32 lines (27 loc) · 764 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
27
28
29
30
31
32
import {isIPv4, isIPv6} from 'node:net';
import {env} from 'node:process';
import {platform} from 'node:os';
import test from 'ava';
import {internalIpV6, internalIpV4, internalIpV6Sync, internalIpV4Sync} from './index.js';
// Only Darwin has IPv6 on GitHub Actions
const canTestV6 = env.CI ? platform() === 'darwin' : true;
test('IPv6 - async', async t => {
if (canTestV6) {
t.true(isIPv6(await internalIpV6()));
} else {
t.is(await internalIpV6(), undefined);
}
});
test('IPv4 - async', async t => {
t.true(isIPv4(await internalIpV4()));
});
test('IPv6 - sync', t => {
if (canTestV6) {
t.true(isIPv6(internalIpV6Sync()));
} else {
t.is(internalIpV6Sync(), undefined);
}
});
test('IPv4 - sync', t => {
t.true(isIPv4(internalIpV4Sync()));
});