mirror of
https://github.com/Unleash/unleash.git
synced 2025-04-10 01:16:39 +02:00
fix: add unit test for lastSeenAt being updated
This commit is contained in:
parent
834010982e
commit
e279a700b8
@ -155,3 +155,30 @@ test('shema allow yes=<string nbr>', t => {
|
|||||||
t.is(value.bucket.toggles.Demo2.yes, 12);
|
t.is(value.bucket.toggles.Demo2.yes, 12);
|
||||||
t.is(value.bucket.toggles.Demo2.no, 256);
|
t.is(value.bucket.toggles.Demo2.no, 256);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should set lastSeen on toggle', async t => {
|
||||||
|
t.plan(1);
|
||||||
|
const { request, stores } = getSetup();
|
||||||
|
stores.featureToggleStore.addFeature({ name: 'toggleLastSeen' });
|
||||||
|
await request
|
||||||
|
.post('/api/client/metrics')
|
||||||
|
.send({
|
||||||
|
appName: 'demo',
|
||||||
|
instanceId: '1',
|
||||||
|
bucket: {
|
||||||
|
start: Date.now(),
|
||||||
|
stop: Date.now(),
|
||||||
|
toggles: {
|
||||||
|
toggleLastSeen: {
|
||||||
|
yes: 200,
|
||||||
|
no: 0,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.expect(202);
|
||||||
|
|
||||||
|
const toggle = await stores.featureToggleStore.getFeature('toggleLastSeen');
|
||||||
|
|
||||||
|
t.truthy(toggle.lastSeenAt);
|
||||||
|
});
|
||||||
|
9
test/fixtures/fake-feature-toggle-store.js
vendored
9
test/fixtures/fake-feature-toggle-store.js
vendored
@ -26,6 +26,13 @@ module.exports = () => {
|
|||||||
addFeature: feature => _features.push(feature),
|
addFeature: feature => _features.push(feature),
|
||||||
getArchivedFeatures: () => Promise.resolve(_archive),
|
getArchivedFeatures: () => Promise.resolve(_archive),
|
||||||
addArchivedFeature: feature => _archive.push(feature),
|
addArchivedFeature: feature => _archive.push(feature),
|
||||||
lastSeenToggles: () => {},
|
lastSeenToggles: (names = []) => {
|
||||||
|
names.forEach(name => {
|
||||||
|
const toggle = _features.find(f => f.name === name);
|
||||||
|
if (toggle) {
|
||||||
|
toggle.lastSeenAt = new Date();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user