mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-04 00:18:01 +01:00
39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
|
import { setupApp } from '../../helpers/test-helper';
|
||
|
import dbInit from '../../helpers/database-init';
|
||
|
import getLogger from '../../../fixtures/no-logger';
|
||
|
|
||
|
let app;
|
||
|
let db;
|
||
|
|
||
|
beforeAll(async () => {
|
||
|
db = await dbInit('openapi', getLogger);
|
||
|
app = await setupApp(db.stores);
|
||
|
});
|
||
|
|
||
|
afterAll(async () => {
|
||
|
await app.destroy();
|
||
|
await db.destroy();
|
||
|
});
|
||
|
|
||
|
test('should serve the OpenAPI UI', async () => {
|
||
|
return app.request
|
||
|
.get('/docs/openapi/')
|
||
|
.expect('Content-Type', /html/)
|
||
|
.expect(200)
|
||
|
.expect((res) => expect(res.text).toMatchSnapshot());
|
||
|
});
|
||
|
|
||
|
test('should serve the OpenAPI spec', async () => {
|
||
|
return app.request
|
||
|
.get('/docs/openapi.json')
|
||
|
.expect('Content-Type', /json/)
|
||
|
.expect(200)
|
||
|
.expect((res) => {
|
||
|
// The version field is not set when running jest without yarn/npm.
|
||
|
delete res.body.info.version;
|
||
|
// This test will fail whenever there's a change to the API spec.
|
||
|
// If the change is intended, update the snapshot with `jest -u`.
|
||
|
expect(res.body).toMatchSnapshot();
|
||
|
});
|
||
|
});
|