1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-28 00:06:53 +01:00
unleash.unleash/src/lib/app.test.ts
2022-01-06 10:31:00 +01:00

43 lines
961 B
TypeScript

import express from 'express';
import { createTestConfig } from '../test/config/test-config';
jest.mock(
'./routes',
() =>
class Index {
router() {
return express.Router();
}
},
);
const getApp = require('./app').default;
test('should not throw when valid config', async () => {
const config = createTestConfig();
const app = await getApp(config, {}, {});
expect(typeof app.listen).toBe('function');
});
test('should call preHook', async () => {
let called = 0;
const config = createTestConfig({
preHook: () => {
called++;
},
});
await getApp(config, {}, {});
expect(called).toBe(1);
});
test('should call preRouterHook', async () => {
let called = 0;
const config = createTestConfig({
preRouterHook: () => {
called++;
},
});
await getApp(config, {}, {});
expect(called).toBe(1);
});