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(); }); test('should be possible to send metrics', async () => { return app.request .post('/api/client/metrics') .send(metricsExample) .expect(202); }); test('should require valid send metrics', async () => { return app.request .post('/api/client/metrics') .send({ appName: 'test', }) .expect(400); }); test('should accept empty client metrics', async () => { return app.request .post('/api/client/metrics') .send({ appName: 'demo', instanceId: '1', bucket: { start: Date.now(), stop: Date.now(), toggles: {}, }, }) .expect(202); });