1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00
unleash.unleash/lib/server-impl.test.js

58 lines
1.1 KiB
JavaScript
Raw Normal View History

'use strict';
2018-12-17 09:24:49 +01:00
const test = require('ava');
const proxyquire = require('proxyquire');
const express = require('express');
const getApp = proxyquire('./app', {
'./routes': class Index {
router() {
return express.Router();
}
},
});
const serverImpl = proxyquire('./server-impl', {
'./app': getApp,
'./metrics': {
2017-06-28 10:17:14 +02:00
startMonitoring(o) {
return o;
},
},
'./db': {
2017-06-28 10:17:14 +02:00
createStores(o) {
return o;
},
},
'./options': {
2017-06-28 10:17:14 +02:00
createOptions(o) {
return o;
},
},
2017-06-28 10:17:14 +02:00
'../migrator'() {
return Promise.resolve();
},
});
test('should call preHook', async t => {
let called = 0;
await serverImpl.start({
port: 0,
preHook: () => {
called++;
},
});
t.true(called === 1);
});
test('should call preRouterHook', async t => {
let called = 0;
await serverImpl.start({
port: 0,
preRouterHook: () => {
called++;
},
});
t.true(called === 1);
});