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/events.test.js

38 lines
969 B
JavaScript
Raw Normal View History

2017-01-06 15:58:02 +01:00
'use strict';
2018-12-17 09:24:49 +01:00
const test = require('ava');
const store = require('./../../../test/fixtures/store');
const getLogger = require('../../../test/fixtures/no-logger');
2017-01-06 15:58:02 +01:00
const supertest = require('supertest');
const getApp = require('../../app');
2017-01-06 15:58:02 +01:00
const { EventEmitter } = require('events');
const eventBus = new EventEmitter();
function getSetup() {
2017-01-06 15:58:02 +01:00
const base = `/random${Math.round(Math.random() * 1000)}`;
const stores = store.createStores();
const app = getApp({
baseUriPath: base,
stores,
eventBus,
getLogger,
2017-01-06 15:58:02 +01:00
});
return { base, eventStore: stores.eventStore, request: supertest(app) };
2017-01-06 15:58:02 +01:00
}
test('should get empty events list via admin', t => {
t.plan(1);
2017-01-06 15:58:02 +01:00
const { request, base } = getSetup();
return request
.get(`${base}/api/admin/events`)
2017-01-06 15:58:02 +01:00
.expect('Content-Type', /json/)
.expect(200)
.expect(res => {
t.true(res.body.events.length === 0);
2017-01-06 15:58:02 +01:00
});
});