fix(webrequest): complete rewrite to v4: migrate API to fetch-compatible function and new WebrequestClient, update tests and docs, and bump dependencies
This commit is contained in:
41
test/test.ts
41
test/test.ts
@@ -2,42 +2,31 @@ import { expect, tap } from '@git.zone/tstest/tapbundle';
|
||||
import { webrequest } from '../ts/index.js';
|
||||
|
||||
// test dependencies
|
||||
import * as typedserver from '@api.global/typedserver';
|
||||
import { TypedServer } from '@api.global/typedserver';
|
||||
|
||||
let testServer: typedserver.servertools.Server;
|
||||
let testServer: TypedServer;
|
||||
|
||||
tap.test('setup test server', async () => {
|
||||
testServer = new typedserver.servertools.Server({
|
||||
testServer = new TypedServer({
|
||||
cors: false,
|
||||
forceSsl: false,
|
||||
port: 2345,
|
||||
});
|
||||
|
||||
testServer.addRoute(
|
||||
'/apiroute1',
|
||||
new typedserver.servertools.Handler('GET', (req, res) => {
|
||||
res.status(500);
|
||||
res.end();
|
||||
}),
|
||||
);
|
||||
testServer.addRoute('/apiroute1', 'GET', async (ctx) => {
|
||||
return new Response(null, { status: 500 });
|
||||
});
|
||||
|
||||
testServer.addRoute(
|
||||
'/apiroute2',
|
||||
new typedserver.servertools.Handler('GET', (req, res) => {
|
||||
res.status(500);
|
||||
res.end();
|
||||
}),
|
||||
);
|
||||
testServer.addRoute('/apiroute2', 'GET', async (ctx) => {
|
||||
return new Response(null, { status: 500 });
|
||||
});
|
||||
|
||||
testServer.addRoute(
|
||||
'/apiroute3',
|
||||
new typedserver.servertools.Handler('GET', (req, res) => {
|
||||
res.status(200);
|
||||
res.send({
|
||||
hithere: 'hi',
|
||||
});
|
||||
}),
|
||||
);
|
||||
testServer.addRoute('/apiroute3', 'GET', async (ctx) => {
|
||||
return new Response(JSON.stringify({ hithere: 'hi' }), {
|
||||
status: 200,
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
});
|
||||
});
|
||||
|
||||
await testServer.start();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user