mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-22 19:07:54 +01:00
ccaab0c47b
Instead of instructing users to do static calls in to Unleash, she should instead be allwed to specify the log provider as an option to Unleash. This commit introduces the "getLogger" option, a function responsible for creating a logger.
58 lines
1.5 KiB
JavaScript
58 lines
1.5 KiB
JavaScript
'use strict';
|
|
|
|
process.env.NODE_ENV = 'test';
|
|
|
|
const supertest = require('supertest');
|
|
|
|
const getApp = require('../../../lib/app');
|
|
const dbInit = require('./database-init');
|
|
const getLogger = require('../../fixtures/no-logger');
|
|
const StateService = require('../../../lib/state-service');
|
|
|
|
const { EventEmitter } = require('events');
|
|
const eventBus = new EventEmitter();
|
|
|
|
function createApp(stores, adminAuthentication = 'none', preHook) {
|
|
return getApp({
|
|
stores,
|
|
eventBus,
|
|
preHook,
|
|
adminAuthentication,
|
|
secret: 'super-secret',
|
|
sessionAge: 4000,
|
|
stateService: new StateService({ stores, getLogger }),
|
|
getLogger,
|
|
});
|
|
}
|
|
|
|
module.exports = {
|
|
async setupApp(name) {
|
|
const stores = await dbInit(name, getLogger);
|
|
const app = createApp(stores);
|
|
|
|
return {
|
|
request: supertest.agent(app),
|
|
destroy: () => stores.db.destroy(),
|
|
};
|
|
},
|
|
async setupAppWithAuth(name) {
|
|
const stores = await dbInit(name, getLogger);
|
|
const app = createApp(stores, 'unsecure');
|
|
|
|
return {
|
|
request: supertest.agent(app),
|
|
destroy: () => stores.db.destroy(),
|
|
};
|
|
},
|
|
|
|
async setupAppWithCustomAuth(name, preHook) {
|
|
const stores = await dbInit(name, getLogger);
|
|
const app = createApp(stores, 'custom', preHook);
|
|
|
|
return {
|
|
request: supertest.agent(app),
|
|
destroy: () => stores.db.destroy(),
|
|
};
|
|
},
|
|
};
|