2021-08-12 15:04:37 +02:00
|
|
|
import supertest from 'supertest';
|
|
|
|
import { EventEmitter } from 'events';
|
|
|
|
import { createServices } from '../../services';
|
|
|
|
import { createTestConfig } from '../../../test/config/test-config';
|
2017-01-06 15:58:02 +01:00
|
|
|
|
2021-08-12 15:04:37 +02:00
|
|
|
import createStores from '../../../test/fixtures/store';
|
2021-05-28 11:10:24 +02:00
|
|
|
|
2021-08-12 15:04:37 +02:00
|
|
|
import getApp from '../../app';
|
2017-01-06 15:58:02 +01:00
|
|
|
|
|
|
|
const eventBus = new EventEmitter();
|
|
|
|
|
2017-06-28 10:20:22 +02:00
|
|
|
function getSetup() {
|
2017-01-06 15:58:02 +01:00
|
|
|
const base = `/random${Math.round(Math.random() * 1000)}`;
|
2021-08-12 15:04:37 +02:00
|
|
|
const stores = createStores();
|
2021-04-22 10:07:10 +02:00
|
|
|
const config = createTestConfig({
|
|
|
|
server: { baseUriPath: base },
|
2017-01-06 15:58:02 +01:00
|
|
|
});
|
2021-04-22 10:07:10 +02:00
|
|
|
const services = createServices(stores, config);
|
|
|
|
const app = getApp(config, stores, services, eventBus);
|
2017-01-06 15:58:02 +01:00
|
|
|
|
2017-06-28 10:20:22 +02:00
|
|
|
return { base, eventStore: stores.eventStore, request: supertest(app) };
|
2017-01-06 15:58:02 +01:00
|
|
|
}
|
|
|
|
|
2021-05-28 11:10:24 +02:00
|
|
|
test('should get empty events list via admin', () => {
|
|
|
|
expect.assertions(1);
|
2017-01-06 15:58:02 +01:00
|
|
|
const { request, base } = getSetup();
|
|
|
|
return request
|
2017-06-28 10:20:22 +02:00
|
|
|
.get(`${base}/api/admin/events`)
|
2017-01-06 15:58:02 +01:00
|
|
|
.expect('Content-Type', /json/)
|
|
|
|
.expect(200)
|
2021-08-12 15:04:37 +02:00
|
|
|
.expect((res) => {
|
2021-05-28 11:10:24 +02:00
|
|
|
expect(res.body.events.length === 0).toBe(true);
|
2017-01-06 15:58:02 +01:00
|
|
|
});
|
|
|
|
});
|