smartnetwork/test/test.ping.ts

26 lines
905 B
TypeScript
Raw Normal View History

import { tap, expect, expectAsync } from '@push.rocks/tapbundle';
2022-02-17 00:03:13 +01:00
2022-03-24 23:11:53 +01:00
import * as smartnetwork from '../ts/index.js';
2022-02-17 00:03:13 +01:00
let testSmartnetwork: smartnetwork.SmartNetwork;
tap.test('should create a vlid instance of SmartNetwork', async () => {
testSmartnetwork = new smartnetwork.SmartNetwork();
expect(testSmartnetwork).toBeInstanceOf(smartnetwork.SmartNetwork);
2022-02-17 00:18:23 +01:00
});
2022-02-17 00:03:13 +01:00
tap.test('should send a ping to Google', async () => {
2022-10-21 17:13:06 +02:00
console.log(await testSmartnetwork.ping('google.com'));
await expectAsync(testSmartnetwork.ping('google.com')).property('alive').toBeTrue();
2022-02-17 00:18:23 +01:00
});
2022-02-17 00:03:13 +01:00
2022-10-21 17:13:06 +02:00
tap.test('should state when a ping is not alive ', async () => {
await expectAsync(testSmartnetwork.ping('notthere.lossless.com')).property('alive').toBeFalse();
});
tap.test('should send a ping to an IP', async () => {
await expectAsync(testSmartnetwork.ping('192.168.186.999')).property('alive').toBeFalse();
})
2022-02-17 00:03:13 +01:00
tap.start();