From 688a7213873633dff34f4895f3f57c2a8697d1d5 Mon Sep 17 00:00:00 2001 From: melancholiai Date: Tue, 20 Sep 2022 17:16:38 +0300 Subject: [PATCH] refactor: jest hooks order --- tests/OpenapiViewerMiddleware.spec.ts | 50 +++++++++++++-------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/tests/OpenapiViewerMiddleware.spec.ts b/tests/OpenapiViewerMiddleware.spec.ts index ef4c39d..3cf64bb 100644 --- a/tests/OpenapiViewerMiddleware.spec.ts +++ b/tests/OpenapiViewerMiddleware.spec.ts @@ -147,34 +147,34 @@ describe('openapiViewerRouter', function () { let openapiViewerRouterFromSpec: OpenapiViewerRouter; let apps: Application[]; - describe('Serve UI', function () { - beforeAll(function () { - // initialize express app using file config - const configUsingFile: OpenapiRouterConfig = { - filePathOrSpec: './openapi.yml', - rawPath: '/api', - uiPath: '/api/ui', - }; - jest.spyOn(fs, 'readFileSync').mockReturnValue(openapiSpec); - openapiViewerRouterFromFile = new OpenapiViewerRouter(configUsingFile); - openapiViewerRouterFromFile.setup(); - expressAppUsingFile = express(); - expressAppUsingFile.use('/docs', openapiViewerRouterFromFile.getRouter()); + beforeAll(function () { + // initialize express app using file config + const configUsingFile: OpenapiRouterConfig = { + filePathOrSpec: './openapi.yml', + rawPath: '/api', + uiPath: '/api/ui', + }; + jest.spyOn(fs, 'readFileSync').mockReturnValue(openapiSpec); + openapiViewerRouterFromFile = new OpenapiViewerRouter(configUsingFile); + openapiViewerRouterFromFile.setup(); + expressAppUsingFile = express(); + expressAppUsingFile.use('/docs', openapiViewerRouterFromFile.getRouter()); - // initialize express app using spec config - const configUsingSpec: OpenapiRouterConfig = { - filePathOrSpec: openapiSpec, - rawPath: '/api', - uiPath: '/api/ui', - }; - openapiViewerRouterFromSpec = new OpenapiViewerRouter(configUsingSpec); - openapiViewerRouterFromSpec.setup(); - expressAppUsingSpec = express(); - expressAppUsingSpec.use('/docs', openapiViewerRouterFromSpec.getRouter()); + // initialize express app using spec config + const configUsingSpec: OpenapiRouterConfig = { + filePathOrSpec: openapiSpec, + rawPath: '/api', + uiPath: '/api/ui', + }; + openapiViewerRouterFromSpec = new OpenapiViewerRouter(configUsingSpec); + openapiViewerRouterFromSpec.setup(); + expressAppUsingSpec = express(); + expressAppUsingSpec.use('/docs', openapiViewerRouterFromSpec.getRouter()); - apps = [expressAppUsingFile, expressAppUsingSpec]; - }); + apps = [expressAppUsingFile, expressAppUsingSpec]; + }); + describe('Serve UI', function () { describe('Happy Path 😀', function () { it('should return 301 status code when requesting the /docs/api/ui', async function () { for await (const app of apps) {