1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-25 00:07:47 +01:00

pass along hooks, add test to server impl

This commit is contained in:
sveisvei 2017-06-06 09:56:29 +02:00 committed by Ivar Conradi Østhus
parent 34d9a6a35f
commit fa6c28de8f
3 changed files with 56 additions and 0 deletions

View File

@ -3,6 +3,9 @@
"finn",
"finn/node"
],
"parserOptions": {
"ecmaVersion": "2017"
},
"rules": {
"max-nested-callbacks": "off"
}

View File

@ -21,6 +21,8 @@ function createApp (options) {
enableRequestLogger: options.enableRequestLogger,
port: options.port,
publicFolder: options.publicFolder,
preRouterHook: options.preRouterHook,
preHook: options.preHook,
stores,
eventBus,
};

51
lib/server-impl.test.js Normal file
View File

@ -0,0 +1,51 @@
'use strict';
const test = require('ava');
const proxyquire = require('proxyquire');
const getApp = proxyquire('./app', {
'./routes': {
createAPI: () => {},
createLegacy: () => {},
},
});
const serverImpl = proxyquire('./server-impl', {
'./app': getApp,
'./metrics': {
startMonitoring (o) {
return o;
},
},
'./db': {
createStores (o) {
return o;
},
},
'./options': {
createOptions (o) {
return o;
},
},
'../migrator' () {
return Promise.resolve();
},
});
test('should call preHook', async t => {
let called = 0;
await serverImpl.start({
preHook: () => {
called++;
},
});
t.true(called === 1);
});
test('should call preRouterHook', async t => {
let called = 0;
await serverImpl.start({ preRouterHook: () => {
called++;
} });
t.true(called === 1);
});