build: switch default to ESM
[poolifier.git] / tests / pools / selection-strategies / weighted-round-robin-worker-choice-strategy.test.mjs
CommitLineData
a074ffee 1import { expect } from 'expect'
d35e5717
JB
2import { FixedThreadPool } from '../../../lib/index.cjs'
3import { WeightedRoundRobinWorkerChoiceStrategy } from '../../../lib/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.cjs'
4import { generateRandomInteger } from '../../test-utils.cjs'
0220f124
JB
5
6describe('Weighted round robin strategy worker choice strategy test suite', () => {
7 // const min = 1
8 const max = 3
9 let pool
10
11 before(() => {
b2fd3f4a
JB
12 pool = new FixedThreadPool(
13 max,
14 './tests/worker-files/thread/testWorker.mjs'
15 )
0220f124
JB
16 })
17
0220f124
JB
18 after(async () => {
19 await pool.destroy()
20 })
21
6cdd998c 22 it('Verify that reset() resets internals', () => {
0220f124 23 const strategy = new WeightedRoundRobinWorkerChoiceStrategy(pool)
bac873bd
JB
24 strategy.currentWorkerId = generateRandomInteger(Number.MAX_SAFE_INTEGER, 1)
25 strategy.workerVirtualTaskRunTime = generateRandomInteger(
08f3f44c
JB
26 Number.MAX_SAFE_INTEGER,
27 1
28 )
516dcb0d 29 expect(strategy.reset()).toBe(true)
9b106837 30 expect(strategy.nextWorkerNodeKey).toBe(0)
54f4e726 31 expect(strategy.previousWorkerNodeKey).toBe(0)
f3a91bac 32 expect(strategy.workerNodeVirtualTaskRunTime).toBe(0)
0220f124
JB
33 })
34})