smartswagger/test/test.ts

36 lines
1.6 KiB
TypeScript

import { expect, tap } from '@pushrocks/tapbundle';
import * as smartswagger from '../ts/index';
import * as smartexpress from '@pushrocks/smartexpress';
let testSmartswaggerInstance: smartswagger.Smartswagger;
let testExpressServer: smartexpress.Server;
tap.test('first test', async () => {
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);
});
tap.test('should run for a few seconds', async (toolsArg) => {
await toolsArg.delayFor(5000);
});
tap.test('should end smartswagger', async () => {
await testExpressServer.stop();
})
tap.start();