1 import { randomInt } from 'node:crypto'
2 import { expect } from 'expect'
3 import { FixedThreadPool } from '../../../lib/index.cjs'
4 import { WeightedRoundRobinWorkerChoiceStrategy } from '../../../lib/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.cjs'
6 describe('Weighted round robin strategy worker choice strategy test suite', () => {
12 pool = new FixedThreadPool(
14 './tests/worker-files/thread/testWorker.mjs'
22 it('Verify that reset() resets internals', () => {
23 const strategy = new WeightedRoundRobinWorkerChoiceStrategy(pool)
24 strategy.currentWorkerId = randomInt(281474976710655)
25 strategy.workerVirtualTaskRunTime = randomInt(281474976710655)
26 expect(strategy.reset()).toBe(true)
27 expect(strategy.nextWorkerNodeKey).toBe(0)
28 expect(strategy.previousWorkerNodeKey).toBe(0)
29 expect(strategy.workerNodeVirtualTaskRunTime).toBe(0)