mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-28 00:06:53 +01:00
cdfba8f7b1
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
35 lines
1.1 KiB
JavaScript
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 });
|
|
});
|