docs: refine code comments
[poolifier.git] / tests / pools / selection-strategies / worker-choice-strategy-context.test.mjs
index bb8c7fefb3a1567919af0736f698c6e6f4a55359..f076f4ddda866dc79735530a8ec4003202dee772 100644 (file)
@@ -95,7 +95,9 @@ describe('Worker choice strategy context test suite', () => {
       workerChoiceStrategyUndefinedStub
     )
     expect(() => workerChoiceStrategyContext.execute()).toThrow(
-      new Error('Worker node key chosen is null or undefined after 6 retries')
+      new Error(
+        `Worker node key chosen is null or undefined after ${fixedPool.info.maxSize} retries`
+      )
     )
     const workerChoiceStrategyNullStub = createStubInstance(
       RoundRobinWorkerChoiceStrategy,
@@ -109,7 +111,9 @@ describe('Worker choice strategy context test suite', () => {
       workerChoiceStrategyNullStub
     )
     expect(() => workerChoiceStrategyContext.execute()).toThrow(
-      new Error('Worker node key chosen is null or undefined after 6 retries')
+      new Error(
+        `Worker node key chosen is null or undefined after ${fixedPool.info.maxSize} retries`
+      )
     )
   })
 
@@ -131,12 +135,6 @@ describe('Worker choice strategy context test suite', () => {
           .returns(false)
           .onCall(4)
           .returns(false)
-          .onCall(6)
-          .returns(false)
-          .onCall(7)
-          .returns(false)
-          .onCall(8)
-          .returns(false)
           .returns(true),
         choose: stub().returns(1)
       }
@@ -153,7 +151,7 @@ describe('Worker choice strategy context test suite', () => {
       workerChoiceStrategyContext.workerChoiceStrategies.get(
         workerChoiceStrategyContext.workerChoiceStrategy
       ).hasPoolWorkerNodesReady.callCount
-    ).toBe(12)
+    ).toBe(6)
     expect(
       workerChoiceStrategyContext.workerChoiceStrategies.get(
         workerChoiceStrategyContext.workerChoiceStrategy
@@ -162,7 +160,7 @@ describe('Worker choice strategy context test suite', () => {
     expect(chosenWorkerKey).toBe(1)
   })
 
-  it('Verify that execute() throws error if worker choice strategy consecutive executions has been reached', () => {
+  it('Verify that execute() throws error if worker choice strategy recursion reach the maximum depth', () => {
     const workerChoiceStrategyContext = new WorkerChoiceStrategyContext(
       fixedPool
     )
@@ -181,9 +179,7 @@ describe('Worker choice strategy context test suite', () => {
       workerChoiceStrategyStub
     )
     expect(() => workerChoiceStrategyContext.execute()).toThrow(
-      new RangeError(
-        'Worker choice strategy consecutive executions has exceeded the maximum of 10000'
-      )
+      new RangeError('Maximum call stack size exceeded')
     )
   })