diff --git a/lib/app.test.js b/lib/app.test.js new file mode 100644 index 0000000000..2124cb10a2 --- /dev/null +++ b/lib/app.test.js @@ -0,0 +1,31 @@ +'use strict'; + +const test = require('ava'); +const proxyquire = require('proxyquire'); +const getApp = proxyquire('./app', { + './routes': { + createAPI: () => {}, + createLegacy: () => {}, + }, +}); + +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; + getApp({ preHook: () => { + called++; + } }); + t.true(called === 1); +}); + +test('should call preRouterHook', t => { + let called = 0; + getApp({ preRouterHook: () => { + called++; + } }); + t.true(called === 1); +}); diff --git a/package.json b/package.json index f0077faa6c..0e3ebdac3a 100644 --- a/package.json +++ b/package.json @@ -85,6 +85,7 @@ "eslint": "^3.11.1", "eslint-config-finn": "^1.0.0-beta.1", "nyc": "^9.0.1", + "proxyquire": "^1.7.10", "sinon": "^1.17.5", "superagent": "^2.3.0", "supertest": "^2.0.1",