From: Jérôme Benoit Date: Tue, 18 Jul 2023 20:58:37 +0000 (+0200) Subject: test: add updateMeasurementStatistics() behavior test X-Git-Tag: v2.6.18~7 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=a91f7b3568bc8d86c3890fe0ece826c239293e20;p=poolifier.git test: add updateMeasurementStatistics() behavior test Signed-off-by: Jérôme Benoit --- diff --git a/tests/utils.test.js b/tests/utils.test.js index f220927e..6518ca92 100644 --- a/tests/utils.test.js +++ b/tests/utils.test.js @@ -5,7 +5,8 @@ const { isKillBehavior, isPlainObject, median, - round + round, + updateMeasurementStatistics } = require('../lib/utils') const { KillBehaviors } = require('../lib/worker/worker-options') @@ -125,4 +126,42 @@ describe('Utils test suite', () => { expect(isAsyncFunction(async function () {})).toBe(true) expect(isAsyncFunction(async function named () {})).toBe(true) }) + + it('Verify updateMeasurementStatistics() behavior', () => { + const measurementStatistics = {} + updateMeasurementStatistics( + measurementStatistics, + { aggregate: true, average: false, median: false }, + 0.01, + 1 + ) + expect(measurementStatistics).toEqual({ + aggregate: 0.01, + maximum: 0.01, + minimum: 0.01 + }) + updateMeasurementStatistics( + measurementStatistics, + { aggregate: true, average: false, median: false }, + 0.02, + 2 + ) + expect(measurementStatistics).toEqual({ + aggregate: 0.03, + maximum: 0.02, + minimum: 0.01 + }) + updateMeasurementStatistics( + measurementStatistics, + { aggregate: true, average: true, median: false }, + 0.001, + 3 + ) + expect(measurementStatistics).toEqual({ + aggregate: 0.031, + maximum: 0.02, + minimum: 0.001, + average: 0.010333333333333333 + }) + }) })