unleash-server
Version:
Unleash is an enterprise ready feature flag service. It provides different strategies for handling feature flags.
85 lines • 2.47 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const calculate_stage_durations_1 = require("./calculate-stage-durations");
test('can find feature lifecycle stage timings', async () => {
const now = new Date();
const oneHourAgo = new Date(now.getTime() - 60 * 60 * 1000);
const twentyMinutesAgo = new Date(now.getTime() - 20 * 60 * 1000);
const tenMinutesAgo = new Date(now.getTime() - 10 * 60 * 1000);
const fiveMinutesAgo = new Date(now.getTime() - 5 * 60 * 1000);
const durations = (0, calculate_stage_durations_1.calculateStageDurations)([
{
feature: 'a',
stage: 'initial',
project: 'default',
enteredStageAt: oneHourAgo,
},
{
feature: 'b',
stage: 'initial',
project: 'default',
enteredStageAt: oneHourAgo,
},
{
feature: 'a',
stage: 'pre-live',
project: 'default',
enteredStageAt: twentyMinutesAgo,
},
{
feature: 'b',
stage: 'live',
project: 'default',
enteredStageAt: tenMinutesAgo,
},
{
feature: 'c',
stage: 'initial',
project: 'default',
enteredStageAt: oneHourAgo,
},
{
feature: 'c',
stage: 'pre-live',
project: 'default',
enteredStageAt: fiveMinutesAgo,
},
]);
expect(durations).toMatchObject([
{
project: 'default',
stage: 'initial',
duration: 50,
},
{
project: 'default',
stage: 'pre-live',
duration: 12.5,
},
{
project: 'default',
stage: 'live',
duration: 10,
},
]);
});
test('should calculate median durations', () => {
const groupedData = {
'Project1/Development': [180, 120, 10],
'Project1/Testing': [240, 60],
};
const medians = (0, calculate_stage_durations_1.calculateMedians)(groupedData);
expect(medians).toMatchObject([
{
project: 'Project1',
stage: 'Development',
duration: 120,
},
{
project: 'Project1',
stage: 'Testing',
duration: 150,
},
]);
});
//# sourceMappingURL=calculate-stage-durations.test.js.map