1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-04 00:18:01 +01:00
unleash.unleash/src/lib/app.test.ts
2021-09-14 19:30:11 +02:00

43 lines
917 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');
test('should not throw when valid config', () => {
const config = createTestConfig();
const app = getApp(config, {}, {});
expect(typeof app.listen).toBe('function');
});
test('should call preHook', () => {
let called = 0;
const config = createTestConfig({
preHook: () => {
called++;
},
});
getApp(config, {}, {});
expect(called).toBe(1);
});
test('should call preRouterHook', () => {
let called = 0;
const config = createTestConfig({
preRouterHook: () => {
called++;
},
});
getApp(config, {}, {});
expect(called).toBe(1);
});