smartnetwork/test/test.ping.ts

26 lines
904 B
TypeScript
Raw Permalink Normal View History

2022-02-16 23:18:23 +00:00
import { tap, expect, expectAsync } from '@pushrocks/tapbundle';
2022-02-16 23:03:13 +00:00
2022-03-24 22:11:53 +00:00
import * as smartnetwork from '../ts/index.js';
2022-02-16 23:03:13 +00: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-16 23:18:23 +00:00
});
2022-02-16 23:03:13 +00:00
tap.test('should send a ping to Google', async () => {
2022-10-21 15:13:06 +00:00
console.log(await testSmartnetwork.ping('google.com'));
await expectAsync(testSmartnetwork.ping('google.com')).property('alive').toBeTrue();
2022-02-16 23:18:23 +00:00
});
2022-02-16 23:03:13 +00:00
2022-10-21 15:13:06 +00: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-16 23:03:13 +00:00
tap.start();