2022-05-05 23:08:30 -04:00
|
|
|
import { SwaggerUIBundle } from 'swagger-ui-dist';
|
2022-05-13 08:08:49 -04:00
|
|
|
import { setHTMLFixture, resetHTMLFixture } from 'helpers/fixtures';
|
2022-05-05 23:08:30 -04:00
|
|
|
import renderOpenApi from '~/blob/openapi';
|
|
|
|
|
|
|
|
jest.mock('swagger-ui-dist');
|
|
|
|
|
|
|
|
describe('OpenAPI blob viewer', () => {
|
|
|
|
const id = 'js-openapi-viewer';
|
|
|
|
const mockEndpoint = 'some/endpoint';
|
|
|
|
|
|
|
|
beforeEach(() => {
|
2022-05-13 08:08:49 -04:00
|
|
|
setHTMLFixture(`<div id="${id}" data-endpoint="${mockEndpoint}"></div>`);
|
2022-05-05 23:08:30 -04:00
|
|
|
renderOpenApi();
|
|
|
|
});
|
|
|
|
|
2022-05-13 08:08:49 -04:00
|
|
|
afterEach(() => {
|
|
|
|
resetHTMLFixture();
|
|
|
|
});
|
|
|
|
|
2022-05-05 23:08:30 -04:00
|
|
|
it('initializes SwaggerUI with the correct configuration', () => {
|
|
|
|
expect(SwaggerUIBundle).toHaveBeenCalledWith({
|
|
|
|
url: mockEndpoint,
|
|
|
|
dom_id: `#${id}`,
|
|
|
|
deepLinking: true,
|
|
|
|
displayOperationId: true,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|