1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-28 00:06:53 +01:00
unleash.unleash/test/e2e/helpers/test-helper.js
Ivar Conradi Østhus cdfba8f7b1 feat: Adds last-seen dat on toggles
When an application updates metrics for a toggle we now
stores the timestamp on the toggle when it was last seen
used by an application. This will make it much easier to
detect toggles not in use anymore.

closes #642
2020-12-22 11:05:00 +01:00

45 lines
1.1 KiB
JavaScript

'use strict';
process.env.NODE_ENV = 'test';
const supertest = require('supertest');
const { EventEmitter } = require('events');
const getApp = require('../../../lib/app');
const getLogger = require('../../fixtures/no-logger');
const { createServices } = require('../../../lib/services');
const eventBus = new EventEmitter();
function createApp(stores, adminAuthentication = 'none', preHook) {
const config = {
stores,
eventBus,
preHook,
adminAuthentication,
secret: 'super-secret',
sessionAge: 4000,
getLogger,
};
const services = createServices(stores, config);
// TODO: use create from server-impl instead?
return getApp(config, services);
}
module.exports = {
async setupApp(stores) {
const app = createApp(stores);
return supertest.agent(app);
},
async setupAppWithAuth(stores) {
const app = createApp(stores, 'unsecure');
return supertest.agent(app);
},
async setupAppWithCustomAuth(stores, preHook) {
const app = createApp(stores, 'custom', preHook);
return supertest.agent(app);
},
};