X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=tests%2Futils.test.mjs;h=fd4f776bf2409c8a725e8d3631be9e8981e545c4;hb=ecab2e2a359a3af2afcca8424d704c920fe1fddf;hp=4b4e1e136119c0249894ba03f31d6245201ca3e0;hpb=26ce26ca8861318068427cc86697103e7a3ddbf4;p=poolifier.git diff --git a/tests/utils.test.mjs b/tests/utils.test.mjs index 4b4e1e13..fd4f776b 100644 --- a/tests/utils.test.mjs +++ b/tests/utils.test.mjs @@ -9,8 +9,8 @@ import { EMPTY_FUNCTION, availableParallelism, average, + buildInternalWorkerChoiceStrategyOptions, exponentialDelay, - getDefaultInternalWorkerChoiceStrategyOptions, getWorkerId, getWorkerType, isAsyncFunction, @@ -35,18 +35,6 @@ describe('Utils test suite', () => { expect(EMPTY_FUNCTION).toStrictEqual(expect.any(Function)) }) - it('Verify getDefaultInternalWorkerChoiceStrategyOptions() values', () => { - const poolMaxSize = 10 - expect( - getDefaultInternalWorkerChoiceStrategyOptions(poolMaxSize) - ).toStrictEqual({ - retries: poolMaxSize, - runTime: { median: false }, - waitTime: { median: false }, - elu: { median: false } - }) - }) - it('Verify DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS values', () => { expect(DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS).toStrictEqual({ aggregate: false, @@ -243,6 +231,24 @@ describe('Utils test suite', () => { expect(max(1, 1)).toBe(1) }) + it('Verify buildInternalWorkerChoiceStrategyOptions() behavior', () => { + const poolMaxSize = 10 + const internalWorkerChoiceStrategyOptions = + buildInternalWorkerChoiceStrategyOptions(poolMaxSize) + expect(internalWorkerChoiceStrategyOptions).toStrictEqual({ + retries: + poolMaxSize + + Object.keys(internalWorkerChoiceStrategyOptions.weights).length, + runTime: { median: false }, + waitTime: { median: false }, + elu: { median: false }, + weights: expect.objectContaining({ + 0: expect.any(Number), + [poolMaxSize - 1]: expect.any(Number) + }) + }) + }) + // it('Verify once()', () => { // let called = 0 // const fn = () => ++called