Add dynamic worker choice strategy change at runtime
[poolifier.git] / tests / pools / thread / dynamic.test.js
index 92fbd9b8f9e128382c5781f45719db104bebb19f..94320429ce6d2cfa9deb956bcfac39f996ab26b9 100644 (file)
@@ -26,7 +26,8 @@ describe('Dynamic thread pool test suite', () => {
     for (let i = 0; i < max * 2; i++) {
       promises.push(pool.execute({ test: 'test' }))
     }
-    expect(pool.workers.length).toBe(max)
+    expect(pool.workers.length).toBeLessThanOrEqual(max)
+    expect(pool.workers.length).toBeGreaterThan(min)
     // The `busy` event is triggered when the number of submitted tasks at once reach the max number of workers in the dynamic pool.
     // So in total numberOfWorkers + 1 times for a loop submitting up to numberOfWorkers * 2 tasks to the dynamic pool.
     expect(poolBusy).toBe(max + 1)