2016-12-29 11:42:54 +01:00
|
|
|
'use strict';
|
|
|
|
|
2017-06-28 10:20:22 +02:00
|
|
|
const { test } = require('ava');
|
|
|
|
const express = require('express');
|
2016-12-29 11:42:54 +01:00
|
|
|
const proxyquire = require('proxyquire');
|
|
|
|
const getApp = proxyquire('./app', {
|
|
|
|
'./routes': {
|
2017-06-28 10:20:22 +02:00
|
|
|
router: () => express.Router(),
|
2016-12-29 11:42:54 +01:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
test('should not throw when valid config', t => {
|
|
|
|
const app = getApp({});
|
|
|
|
t.true(typeof app.listen === 'function');
|
|
|
|
});
|
|
|
|
|
|
|
|
test('should call preHook', t => {
|
|
|
|
let called = 0;
|
2017-06-28 10:17:14 +02:00
|
|
|
getApp({
|
|
|
|
preHook: () => {
|
|
|
|
called++;
|
|
|
|
},
|
|
|
|
});
|
2016-12-29 11:42:54 +01:00
|
|
|
t.true(called === 1);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('should call preRouterHook', t => {
|
|
|
|
let called = 0;
|
2017-06-28 10:17:14 +02:00
|
|
|
getApp({
|
|
|
|
preRouterHook: () => {
|
|
|
|
called++;
|
|
|
|
},
|
|
|
|
});
|
2016-12-29 11:42:54 +01:00
|
|
|
t.true(called === 1);
|
|
|
|
});
|