fix(tests): Update dev dependencies and refactor test assertions for improved clarity
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import { tap, expect, expectAsync } from '@push.rocks/tapbundle';
|
||||
import { tap, expect } from '@git.zone/tstest/tapbundle';
|
||||
import { SmartNetwork, NetworkError } from '../ts/index.js';
|
||||
import * as net from 'net';
|
||||
import type { AddressInfo } from 'net';
|
||||
@ -61,7 +61,7 @@ tap.test('traceroute fallback stub returns a single-hop stub', async () => {
|
||||
const sn = new SmartNetwork();
|
||||
const hops = await sn.traceroute('example.com', { maxHops: 5 });
|
||||
expect(Array.isArray(hops)).toBeTrue();
|
||||
expect(hops).toHaveLength(1);
|
||||
expect(hops).array.toHaveLength(1);
|
||||
expect(hops[0]).toEqual({ ttl: 1, ip: 'example.com', rtt: null });
|
||||
});
|
||||
|
||||
@ -166,7 +166,7 @@ tap.test('isLocalPortUnused should detect used local port', async () => {
|
||||
// port is now in use
|
||||
const inUse = await sn.isLocalPortUnused(addr.port);
|
||||
expect(inUse).toBeFalse();
|
||||
await new Promise<void>((res) => server.close(res));
|
||||
await new Promise<void>((resolve) => server.close(() => resolve()));
|
||||
});
|
||||
// Real traceroute integration test (skipped if `traceroute` binary is unavailable)
|
||||
tap.test('traceroute real integration against google.com', async () => {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { tap, expect, expectAsync } from '@push.rocks/tapbundle';
|
||||
import { tap, expect } from '@git.zone/tstest/tapbundle';
|
||||
|
||||
import * as smartnetwork from '../ts/index.js';
|
||||
|
||||
@ -20,11 +20,11 @@ tap.test('should send a ping to Google', async () => {
|
||||
});
|
||||
|
||||
tap.test('should state when a ping is not alive ', async () => {
|
||||
await expectAsync(testSmartnetwork.ping('notthere.lossless.com')).property('alive').toBeFalse();
|
||||
await expect(testSmartnetwork.ping('notthere.lossless.com')).resolves.property('alive').toBeFalse();
|
||||
});
|
||||
|
||||
tap.test('should send a ping to an IP', async () => {
|
||||
await expectAsync(testSmartnetwork.ping('192.168.186.999')).property('alive').toBeFalse();
|
||||
await expect(testSmartnetwork.ping('192.168.186.999')).resolves.property('alive').toBeFalse();
|
||||
});
|
||||
|
||||
tap.start();
|
||||
|
10
test/test.ts
10
test/test.ts
@ -1,4 +1,4 @@
|
||||
import { expect, expectAsync, tap } from '@push.rocks/tapbundle';
|
||||
import { expect, tap } from '@git.zone/tstest/tapbundle';
|
||||
import * as smartnetwork from '../ts/index.js';
|
||||
|
||||
let testSmartNetwork: smartnetwork.SmartNetwork;
|
||||
@ -20,13 +20,13 @@ tap.test('should perform a speedtest', async () => {
|
||||
});
|
||||
|
||||
tap.test('should determine wether a port is free', async () => {
|
||||
await expectAsync(testSmartNetwork.isLocalPortUnused(8080)).toBeTrue();
|
||||
await expect(testSmartNetwork.isLocalPortUnused(8080)).resolves.toBeTrue();
|
||||
});
|
||||
|
||||
tap.test('should scan a port', async () => {
|
||||
await expectAsync(testSmartNetwork.isRemotePortAvailable('lossless.com:443')).toBeTrue();
|
||||
await expectAsync(testSmartNetwork.isRemotePortAvailable('lossless.com', 443)).toBeTrue();
|
||||
await expectAsync(testSmartNetwork.isRemotePortAvailable('lossless.com:444')).toBeFalse();
|
||||
await expect(testSmartNetwork.isRemotePortAvailable('lossless.com:443')).resolves.toBeTrue();
|
||||
await expect(testSmartNetwork.isRemotePortAvailable('lossless.com', 443)).resolves.toBeTrue();
|
||||
await expect(testSmartNetwork.isRemotePortAvailable('lossless.com:444')).resolves.toBeFalse();
|
||||
});
|
||||
|
||||
tap.test('should get gateways', async () => {
|
||||
|
Reference in New Issue
Block a user