2022-11-25 23:54:43 +05:30
|
|
|
import axios from 'axios';
|
|
|
|
import MockAdapter from 'axios-mock-adapter';
|
2022-07-16 23:28:13 +05:30
|
|
|
import { setHTMLFixture, resetHTMLFixture } from 'helpers/fixtures';
|
|
|
|
import renderOpenApi from '~/blob/openapi';
|
|
|
|
|
|
|
|
describe('OpenAPI blob viewer', () => {
|
|
|
|
const id = 'js-openapi-viewer';
|
|
|
|
const mockEndpoint = 'some/endpoint';
|
2022-11-25 23:54:43 +05:30
|
|
|
let mock;
|
2022-07-16 23:28:13 +05:30
|
|
|
|
2022-11-25 23:54:43 +05:30
|
|
|
beforeEach(async () => {
|
2022-07-16 23:28:13 +05:30
|
|
|
setHTMLFixture(`<div id="${id}" data-endpoint="${mockEndpoint}"></div>`);
|
2022-11-25 23:54:43 +05:30
|
|
|
mock = new MockAdapter(axios).onGet().reply(200);
|
|
|
|
await renderOpenApi();
|
2022-07-16 23:28:13 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
resetHTMLFixture();
|
2022-11-25 23:54:43 +05:30
|
|
|
mock.restore();
|
2022-07-16 23:28:13 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('initializes SwaggerUI with the correct configuration', () => {
|
2022-11-25 23:54:43 +05:30
|
|
|
expect(document.body.innerHTML).toContain(
|
|
|
|
'<iframe src="/-/sandbox/swagger" sandbox="allow-scripts allow-popups" frameborder="0" width="100%" height="1000"></iframe>',
|
|
|
|
);
|
2022-07-16 23:28:13 +05:30
|
|
|
});
|
|
|
|
});
|