Merge dependabot/npm_and_yarn/examples/typescript/websocket-server-pool/ws-hybrid...
[poolifier.git] / tests / utils.test.mjs
index 5e089e291f07877506ff12a3373ca407ee2b5c51..5f54f6fc8ea4e0ebe7d7f6ebc27f0efb8a5ea218 100644 (file)
@@ -244,6 +244,21 @@ describe('Utils test suite', () => {
       './tests/worker-files/thread/testWorker.mjs'
     )
     expect(getWorkerChoiceStrategyRetries(pool)).toBe(pool.info.maxSize * 2)
+    const workerChoiceStrategyOptions = {
+      runTime: { median: true },
+      waitTime: { median: true },
+      elu: { median: true },
+      weights: {
+        0: 100,
+        1: 100
+      }
+    }
+    expect(
+      getWorkerChoiceStrategyRetries(pool, workerChoiceStrategyOptions)
+    ).toBe(
+      pool.info.maxSize +
+        Object.keys(workerChoiceStrategyOptions.weights).length
+    )
     await pool.destroy()
   })
 
@@ -262,6 +277,18 @@ describe('Utils test suite', () => {
         [pool.info.maxSize - 1]: expect.any(Number)
       })
     })
+    const workerChoiceStrategyOptions = {
+      runTime: { median: true },
+      waitTime: { median: true },
+      elu: { median: true },
+      weights: {
+        0: 100,
+        1: 100
+      }
+    }
+    expect(
+      buildWorkerChoiceStrategyOptions(pool, workerChoiceStrategyOptions)
+    ).toStrictEqual(workerChoiceStrategyOptions)
     await pool.destroy()
   })