1 const { expect
} = require('expect')
3 DEFAULT_CIRCULAR_ARRAY_SIZE
,
5 } = require('../../lib/circular-array')
6 const { updateMeasurementStatistics
} = require('../../lib/pools/utils')
8 describe('Pool utils test suite', () => {
9 it('Verify updateMeasurementStatistics() behavior', () => {
10 const measurementStatistics
= {
11 history
: new CircularArray()
13 updateMeasurementStatistics(
14 measurementStatistics
,
15 { aggregate
: true, average
: false, median
: false },
18 expect(measurementStatistics
).toStrictEqual({
22 history
: new CircularArray()
24 updateMeasurementStatistics(
25 measurementStatistics
,
26 { aggregate
: true, average
: false, median
: false },
29 expect(measurementStatistics
).toStrictEqual({
33 history
: new CircularArray()
35 updateMeasurementStatistics(
36 measurementStatistics
,
37 { aggregate
: true, average
: true, median
: false },
40 expect(measurementStatistics
).toStrictEqual({
45 history
: new CircularArray(DEFAULT_CIRCULAR_ARRAY_SIZE
, 0.001)
47 updateMeasurementStatistics(
48 measurementStatistics
,
49 { aggregate
: true, average
: true, median
: false },
52 expect(measurementStatistics
).toStrictEqual({
57 history
: new CircularArray(DEFAULT_CIRCULAR_ARRAY_SIZE
, 0.001, 0.003)
59 updateMeasurementStatistics(
60 measurementStatistics
,
61 { aggregate
: true, average
: false, median
: true },
64 expect(measurementStatistics
).toStrictEqual({
69 history
: new CircularArray(
70 DEFAULT_CIRCULAR_ARRAY_SIZE
,
76 updateMeasurementStatistics(
77 measurementStatistics
,
78 { aggregate
: true, average
: true, median
: false },
81 expect(measurementStatistics
).toStrictEqual({
86 history
: new CircularArray(
87 DEFAULT_CIRCULAR_ARRAY_SIZE
,