1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-25 00:07:47 +01:00
unleash.unleash/src/test/e2e/api/client/metrics.e2e.test.ts

49 lines
1.2 KiB
TypeScript
Raw Normal View History

2021-09-14 20:17:13 +02:00
import { setupApp } from '../../helpers/test-helper';
import metricsExample from '../../../examples/client-metrics.json';
import dbInit from '../../helpers/database-init';
import getLogger from '../../../fixtures/no-logger';
let app;
let db;
beforeAll(async () => {
db = await dbInit('metrics_api_client', getLogger);
app = await setupApp(db.stores);
});
afterAll(async () => {
await app.destroy();
await db.destroy();
});
2017-12-18 14:21:11 +01:00
test('should be possible to send metrics', async () => {
return app.request
2017-12-18 14:21:11 +01:00
.post('/api/client/metrics')
.send(metricsExample)
.expect(202);
2017-12-18 14:21:11 +01:00
});
test('should require valid send metrics', async () => {
return app.request
2017-12-18 14:21:11 +01:00
.post('/api/client/metrics')
.send({
appName: 'test',
})
.expect(400);
2017-12-18 14:21:11 +01:00
});
2020-09-25 09:39:12 +02:00
test('should accept empty client metrics', async () => {
return app.request
2020-09-25 09:39:12 +02:00
.post('/api/client/metrics')
.send({
appName: 'demo',
instanceId: '1',
bucket: {
start: Date.now(),
stop: Date.now(),
toggles: {},
},
})
.expect(202);
});