X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=tests%2Futils.test.mjs;h=4b4e1e136119c0249894ba03f31d6245201ca3e0;hb=d62fc5e18631cc99b49c6792c00dc36fa70339e0;hp=ac544f89c5a2f504a6c768c212461e30a8467ee9;hpb=d91689fda0fa7a85014ac25276cf2cf0a9d81ce2;p=poolifier.git diff --git a/tests/utils.test.mjs b/tests/utils.test.mjs index ac544f89..4b4e1e13 100644 --- a/tests/utils.test.mjs +++ b/tests/utils.test.mjs @@ -6,11 +6,11 @@ import { expect } from 'expect' import { DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS, DEFAULT_TASK_NAME, - DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS, EMPTY_FUNCTION, availableParallelism, average, exponentialDelay, + getDefaultInternalWorkerChoiceStrategyOptions, getWorkerId, getWorkerType, isAsyncFunction, @@ -19,7 +19,7 @@ import { max, median, min, - once, + // once, round, secureRandom, sleep @@ -35,9 +35,12 @@ describe('Utils test suite', () => { expect(EMPTY_FUNCTION).toStrictEqual(expect.any(Function)) }) - it('Verify DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS values', () => { - expect(DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS).toStrictEqual({ - retries: 6, + it('Verify getDefaultInternalWorkerChoiceStrategyOptions() values', () => { + const poolMaxSize = 10 + expect( + getDefaultInternalWorkerChoiceStrategyOptions(poolMaxSize) + ).toStrictEqual({ + retries: poolMaxSize, runTime: { median: false }, waitTime: { median: false }, elu: { median: false } @@ -83,9 +86,10 @@ describe('Utils test suite', () => { it('Verify sleep() behavior', async () => { const start = performance.now() - await sleep(1000) + const sleepMs = 1000 + await sleep(sleepMs) const elapsed = performance.now() - start - expect(elapsed).toBeGreaterThanOrEqual(999) + expect(elapsed).toBeGreaterThanOrEqual(sleepMs - 1) }) it('Verify exponentialDelay() behavior', () => { @@ -239,18 +243,18 @@ describe('Utils test suite', () => { expect(max(1, 1)).toBe(1) }) - it('Verify once()', () => { - let called = 0 - const fn = () => ++called - const onceFn = once(fn, this) - const result1 = onceFn() - expect(called).toBe(1) - expect(result1).toBe(1) - const result2 = onceFn() - expect(called).toBe(1) - expect(result2).toBe(1) - const result3 = onceFn() - expect(called).toBe(1) - expect(result3).toBe(1) - }) + // it('Verify once()', () => { + // let called = 0 + // const fn = () => ++called + // const onceFn = once(fn, this) + // const result1 = onceFn() + // expect(called).toBe(1) + // expect(result1).toBe(1) + // const result2 = onceFn() + // expect(called).toBe(1) + // expect(result2).toBe(1) + // const result3 = onceFn() + // expect(called).toBe(1) + // expect(result3).toBe(1) + // }) })