1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-10-18 20:09:08 +02:00
unleash.unleash/src/lib/app.test.js
Christopher Kolstad 240c6a77a1
Feat/options need types (#794)
feat: options are now typed

- This makes it easier to know what to send to unleash.start / unleash.create
- Using a Partial to instantiate the config, then melding it with defaults to get a config object with all fields set either to their defaults or to whatever is passed in.


Co-authored-by: Fredrik Strand Oseberg <fredrik.no@gmail.com>
Co-authored-by: Ivar Conradi Østhus <ivarconr@gmail.com>
2021-04-22 10:07:10 +02:00

44 lines
959 B
JavaScript

'use strict';
import { createTestConfig } from '../test/config/test-config';
const test = require('ava');
const express = require('express');
const proxyquire = require('proxyquire');
const getApp = proxyquire('./app', {
'./routes': class Index {
router() {
return express.Router();
}
},
});
test('should not throw when valid config', t => {
const config = createTestConfig();
const app = getApp(config, {}, {});
t.true(typeof app.listen === 'function');
});
test('should call preHook', t => {
let called = 0;
const config = createTestConfig({
preHook: () => {
called++;
},
});
getApp(config, {}, {});
t.true(called === 1);
});
test('should call preRouterHook', t => {
let called = 0;
const config = createTestConfig({
preRouterHook: () => {
called++;
},
});
getApp(config, {}, {});
t.true(called === 1);
});