1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-28 00:06:53 +01:00
unleash.unleash/lib/routes/admin-api/config.test.js
ivaosthu ccaab0c47b fix: LogProvider as option injected to unleash.
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.
2020-02-20 08:34:24 +01:00

47 lines
1.1 KiB
JavaScript

'use strict';
const test = require('ava');
const store = require('./../../../test/fixtures/store');
const getLogger = require('../../../test/fixtures/no-logger');
const supertest = require('supertest');
const getApp = require('../../app');
const { EventEmitter } = require('events');
const eventBus = new EventEmitter();
const uiConfig = {
headerBackground: 'red',
slogan: 'hello',
};
function getSetup() {
const base = `/random${Math.round(Math.random() * 1000)}`;
const stores = store.createStores();
const app = getApp({
baseUriPath: base,
stores,
eventBus,
extendedPermissions: false,
ui: uiConfig,
getLogger,
});
return {
base,
request: supertest(app),
};
}
test('should get ui config', t => {
t.plan(2);
const { request, base } = getSetup();
return request
.get(`${base}/api/admin/ui-config`)
.expect('Content-Type', /json/)
.expect(200)
.expect(res => {
t.true(res.body.slogan === 'hello');
t.true(res.body.headerBackground === 'red');
});
});