1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-10-18 20:09:08 +02:00
unleash.unleash/src/lib/app.test.ts

43 lines
961 B
TypeScript
Raw Normal View History

2021-09-14 19:30:11 +02:00
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;
2016-12-29 11:42:54 +01:00
test('should not throw when valid config', async () => {
const config = createTestConfig();
const app = await getApp(config, {}, {});
expect(typeof app.listen).toBe('function');
2016-12-29 11:42:54 +01:00
});
test('should call preHook', async () => {
2016-12-29 11:42:54 +01:00
let called = 0;
const config = createTestConfig({
2017-06-28 10:17:14 +02:00
preHook: () => {
called++;
},
});
await getApp(config, {}, {});
expect(called).toBe(1);
2016-12-29 11:42:54 +01:00
});
test('should call preRouterHook', async () => {
2016-12-29 11:42:54 +01:00
let called = 0;
const config = createTestConfig({
2017-06-28 10:17:14 +02:00
preRouterHook: () => {
called++;
},
});
await getApp(config, {}, {});
expect(called).toBe(1);
2016-12-29 11:42:54 +01:00
});