From a91f7b3568bc8d86c3890fe0ece826c239293e20 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Tue, 18 Jul 2023 22:58:37 +0200 Subject: [PATCH] test: add updateMeasurementStatistics() behavior test MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- tests/utils.test.js | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) 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 + }) + }) }) -- 2.34.1