fix(core): update

This commit is contained in:
2022-05-29 20:22:42 +02:00
parent 184bf11bd7
commit 609c3833b1
7 changed files with 837 additions and 444 deletions

View File

@ -1,10 +1,10 @@
import { expect, tap } from '@pushrocks/tapbundle';
import * as webrequest from '../ts/index.js';
tap.test('first test', async (tools) => {
tap.test('should run multiendpoint request', async (tools) => {
const done = tools.defer();
const response = await new webrequest.WebRequest()
.request(['https://lossless.com'], {
.requestMultiEndpoint(['https://lossless.com'], {
method: 'GET',
})
.catch((e) => {

View File

@ -43,12 +43,14 @@ tap.test('setup test server', async () => {
});
tap.test('first test', async (tools) => {
const response = await new webrequest.WebRequest().getJson([
const response = await (await new webrequest.WebRequest().requestMultiEndpoint([
'http://localhost:2345/apiroute1',
'http://localhost:2345/apiroute2',
'http://localhost:2345/apiroute4',
'http://localhost:2345/apiroute3',
]);
], {
method: 'GET'
})).json();
const response2 = await new webrequest.WebRequest().getJson('http://localhost:2345/apiroute3');
@ -59,8 +61,13 @@ tap.test('first test', async (tools) => {
expect(response2).toHaveProperty('hithere'); //.to.equal('hi');
});
tap.test('tear down server', async () => {
testServer.stop();
});
tap.test('should cache response', async () => {
const webrequestInstance = new webrequest.WebRequest();
const response = await webrequestInstance.getJson('http://localhost:2345/apiroute3', true);
expect(response).toHaveProperty('hithere');
await testServer.stop();
const response2 = await webrequestInstance.getJson('http://localhost:2345/apiroute3', true);
expect(response2).toHaveProperty('hithere');
})
tap.start();