smartswagger/test/test.ts

36 lines
1.6 KiB
TypeScript
Raw Normal View History

2021-11-19 19:05:52 +00:00
import { expect, tap } from '@pushrocks/tapbundle';
import * as smartswagger from '../ts/index';
2021-11-20 19:32:16 +00:00
import * as smartexpress from '@pushrocks/smartexpress';
let testSmartswaggerInstance: smartswagger.Smartswagger;
let testExpressServer: smartexpress.Server;
2021-11-19 19:05:52 +00:00
tap.test('first test', async () => {
2021-11-20 19:32:16 +00:00
testSmartswaggerInstance = await smartswagger.Smartswagger.createFromUrl('https://my.sevdesk.de/OpenAPI/ReceiptAPI/openApi.json');
await testSmartswaggerInstance.mergeDocumentFromUrl('https://my.sevdesk.de/OpenAPI/ContactAPI/openApi.json', '');
await testSmartswaggerInstance.mergeDocumentFromUrl('https://my.sevdesk.de/OpenAPI/InvoiceAPI/openApi.json', '');
await testSmartswaggerInstance.mergeDocumentFromUrl('https://my.sevdesk.de/OpenAPI/OrderAPI/openApi.json', '');
await testSmartswaggerInstance.mergeDocumentFromUrl('https://my.sevdesk.de/OpenAPI/InventoryAPI/openApi.json', '');
// express stuff
testExpressServer = new smartexpress.Server({
cors: true,
});
testExpressServer.addRoute('/apiui', new smartexpress.Handler('ALL', testSmartswaggerInstance.getSlashApiUiMiddleware()));
testExpressServer.addRoute('/apiredoc', new smartexpress.Handler('ALL', testSmartswaggerInstance.getSlashRedocMiddleware()))
testExpressServer.addRoute('/apischema', new smartexpress.Handler('ALL', testSmartswaggerInstance.getSlashApiSchemaMiddleware()));
await testExpressServer.start(3000);
2021-11-19 19:05:52 +00:00
});
2021-11-20 19:32:16 +00:00
tap.test('should run for a few seconds', async (toolsArg) => {
await toolsArg.delayFor(5000);
});
tap.test('should end smartswagger', async () => {
await testExpressServer.stop();
})
2021-11-19 19:05:52 +00:00
tap.start();