mirror of
https://github.com/Unleash/unleash.git
synced 2024-11-01 19:07:38 +01:00
3a65847aa7
* Migrate to jest * Use --force-exit until dns close handle issue https://github.com/facebook/jest/issues/9982 Co-authored-by: Ivar Conradi Østhus <ivarconr@gmail.com>
45 lines
942 B
JavaScript
45 lines
942 B
JavaScript
'use strict';
|
|
|
|
const express = require('express');
|
|
const { createTestConfig } = require('../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);
|
|
});
|