1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-28 00:06:53 +01:00
unleash.unleash/lib/services/client-metrics/projection.test.js
Ivar Conradi Østhus cdfba8f7b1 feat: Adds last-seen dat on toggles
When an application updates metrics for a toggle we now
stores the timestamp on the toggle when it was last seen
used by an application. This will make it much easier to
detect toggles not in use anymore.

closes #642
2020-12-22 11:05:00 +01:00

35 lines
1.1 KiB
JavaScript

'use strict';
const test = require('ava');
const Projection = require('./projection');
test('should return set empty if missing', t => {
const projection = new Projection();
projection.substract('name-1', { yes: 1, no: 2 });
t.deepEqual(projection.getProjection()['name-1'], { yes: 0, no: 0 });
});
test('should add and substract', t => {
const projection = new Projection();
t.truthy(projection.store);
projection.add('name-1', { yes: 1, no: 2 });
t.deepEqual(projection.getProjection()['name-1'], { yes: 1, no: 2 });
projection.add('name-1', { yes: 1, no: 2 });
t.deepEqual(projection.getProjection()['name-1'], { yes: 2, no: 4 });
projection.substract('name-1', { yes: 1, no: 2 });
t.deepEqual(projection.getProjection()['name-1'], { yes: 1, no: 2 });
projection.substract('name-1', { yes: 1, no: 2 });
t.deepEqual(projection.getProjection()['name-1'], { yes: 0, no: 0 });
projection.substract('name-2', { yes: 23213, no: 23213 });
projection.add('name-2', { yes: 3, no: 2 });
t.deepEqual(projection.getProjection()['name-2'], { yes: 3, no: 2 });
});