Skip to content

Commit

Permalink
refactor: jest hooks order
Browse files Browse the repository at this point in the history
  • Loading branch information
melancholiai committed Sep 20, 2022
1 parent 325d572 commit 688a721
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions tests/OpenapiViewerMiddleware.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 688a721

Please sign in to comment.