detector/test/test.ts

22 lines
645 B
TypeScript
Raw Normal View History

2021-04-12 19:00:08 +00:00
import { expect, tap } from '@pushrocks/tapbundle';
2022-07-16 16:15:23 +00:00
import * as detector from '../ts/index.js';
2021-04-12 19:00:08 +00:00
2021-04-13 08:30:33 +00:00
let testDetector: detector.Detector;
2021-04-12 19:00:08 +00:00
tap.test('first test', async () => {
2021-04-13 08:30:33 +00:00
testDetector = new detector.Detector();
2022-07-16 16:15:23 +00:00
expect(testDetector).toBeInstanceOf(detector.Detector);
2021-04-13 08:30:33 +00:00
});
2021-04-14 11:47:51 +00:00
tap.test('should detect an closed port on a local domain', async () => {
const result = await testDetector.isActive('http://localhost:3008');
2022-07-16 16:15:23 +00:00
expect(result).toBeFalse();
2021-04-14 11:47:51 +00:00
});
tap.test('should detect an open port on a remote domain', async () => {
2021-04-13 08:30:33 +00:00
const result = await testDetector.isActive('https://lossless.com');
2022-07-16 16:15:23 +00:00
expect(result).toBeTrue();
2021-04-12 19:00:08 +00:00
});
tap.start();