1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-06 00:07:44 +01:00
unleash.unleash/src/lib/routes/health-check.test.ts

44 lines
1.1 KiB
TypeScript
Raw Normal View History

import supertest from 'supertest';
import { createServices } from '../services';
import { createTestConfig } from '../../test/config/test-config';
2016-11-13 15:31:10 +01:00
import createStores from '../../test/fixtures/store';
import getLogger from '../../test/fixtures/no-logger';
import getApp from '../app';
2016-11-13 15:31:10 +01:00
async function getSetup() {
const stores = createStores();
const config = createTestConfig();
const services = createServices(stores, config);
const app = await getApp(config, stores, services);
2016-11-13 15:31:10 +01:00
return {
request: supertest(app),
stores,
2016-11-13 15:31:10 +01:00
};
}
let request;
beforeEach(async () => {
const setup = await getSetup();
request = setup.request;
});
2016-11-13 15:31:10 +01:00
afterEach(() => {
2021-01-06 13:25:25 +01:00
getLogger.setMuteError(false);
});
test('should give 200 when ready', async () => {
await request.get('/health').expect(200);
2016-11-13 15:31:10 +01:00
});
test('should give health=GOOD when ready', async () => {
expect.assertions(2);
await request
2017-11-02 09:23:38 +01:00
.get('/health')
.expect(200)
.expect((res) => {
expect(res.status).toBe(200);
expect(res.body.health).toBe('GOOD');
2017-11-02 09:23:38 +01:00
});
2016-11-13 15:31:10 +01:00
});