1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-20 00:08:02 +01:00

chore: add a test to verify eventHook registration

This commit is contained in:
ivaosthu 2019-06-18 19:59:24 +02:00 committed by Ivar Conradi Østhus
parent 6aefe18440
commit f4667fa767

View File

@ -2,6 +2,7 @@
const test = require('ava');
const proxyquire = require('proxyquire');
const { EventEmitter } = require('events');
const express = require('express');
const getLogger = require('../test/fixtures/no-logger');
@ -13,6 +14,8 @@ const getApp = proxyquire('./app', {
},
});
const eventStore = new EventEmitter();
const serverImpl = proxyquire('./server-impl', {
'./app': getApp,
'./metrics': {
@ -21,8 +24,10 @@ const serverImpl = proxyquire('./server-impl', {
},
},
'./db': {
createStores(o) {
return o;
createStores() {
return {
eventStore,
};
},
},
'./options': {
@ -58,3 +63,16 @@ test('should call preRouterHook', async t => {
});
t.true(called === 1);
});
test('should call eventHook', async t => {
let called = 0;
await serverImpl.start({
port: 0,
getLogger,
eventHook: () => {
called++;
},
});
eventStore.emit('feature-created', {});
t.true(called === 1);
});