X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=test%2Futils%2FStatisticUtils.test.ts;h=d9aadf0c5e77426f6170104799048ba79533c426;hb=6f8914baad517724c82ceeb9bc27672cdb7e31e2;hp=2910c32df23212ded8217b76a4f0f78ab58e578d;hpb=d58b442097da31f8b974d51aef63c64470d9ab48;p=e-mobility-charging-stations-simulator.git diff --git a/test/utils/StatisticUtils.test.ts b/test/utils/StatisticUtils.test.ts index 2910c32d..d9aadf0c 100644 --- a/test/utils/StatisticUtils.test.ts +++ b/test/utils/StatisticUtils.test.ts @@ -1,16 +1,25 @@ +import { describe, it } from 'node:test'; + import { expect } from 'expect'; -import { median, nthPercentile, stdDeviation } from '../../src/utils/StatisticUtils'; +import { average, median, nthPercentile, stdDeviation } from '../../src/utils/StatisticUtils'; + +await describe('StatisticUtils test suite', async () => { + await it('Verify average()', () => { + expect(average([])).toBe(0); + expect(average([0.08])).toBe(0.08); + expect(average([0.25, 4.75, 3.05, 6.04, 1.01, 2.02, 5.03])).toBe(3.1642857142857146); + expect(average([0.25, 4.75, 3.05, 6.04, 1.01, 2.02])).toBe(2.8533333333333335); + }); -describe('StatisticUtils test suite', () => { - it('Verify median()', () => { + await it('Verify median()', () => { expect(median([])).toBe(0); expect(median([0.08])).toBe(0.08); expect(median([0.25, 4.75, 3.05, 6.04, 1.01, 2.02, 5.03])).toBe(3.05); expect(median([0.25, 4.75, 3.05, 6.04, 1.01, 2.02])).toBe(2.535); }); - it('Verify nthPercentile()', () => { + await it('Verify nthPercentile()', () => { expect(nthPercentile([], 25)).toBe(0); expect(nthPercentile([0.08], 50)).toBe(0.08); const array0 = [0.25, 4.75, 3.05, 6.04, 1.01, 2.02, 5.03]; @@ -23,7 +32,7 @@ describe('StatisticUtils test suite', () => { expect(nthPercentile(array0, 100)).toBe(6.04); }); - it('Verify stdDeviation()', () => { + await it('Verify stdDeviation()', () => { expect(stdDeviation([0.25, 4.75, 3.05, 6.04, 1.01, 2.02, 5.03])).toBe(2.0256064851429216); }); });