typedserver/test/test.reload.ts

32 lines
871 B
TypeScript
Raw Permalink Normal View History

2023-08-03 18:45:09 +00:00
import { tap, expect } from '@push.rocks/tapbundle';
import * as smartpath from '@push.rocks/smartpath';
2023-03-29 12:54:07 +00:00
import { TypedServer } from '../ts/index.js';
let testTypedServer: TypedServer;
tap.test('should create a valid instance of TypedServer', async () => {
testTypedServer = new TypedServer({
injectReload: true,
port: 3000,
serveDir: smartpath.get.dirnameFromImportMetaUrl(import.meta.url),
watch: true,
2023-03-30 13:15:48 +00:00
cors: true,
2023-03-29 12:54:07 +00:00
});
expect(testTypedServer).toBeInstanceOf(TypedServer);
});
tap.test('should start to serve files', async (tools) => {
await testTypedServer.start();
await tools.delayFor(5000);
await testTypedServer.reload();
await tools.delayFor(5000);
await testTypedServer.reload();
});
tap.test('should stop to serve files ', async (tools) => {
await tools.delayFor(5000);
await testTypedServer.stop();
});
tap.start();