Merge pull request #747 from poolifier/multiple-functions
[poolifier.git] / tests / pools / abstract / abstract-pool.test.js
index 366d4965960f6eddfb17856331fab8542b44fce3..81ae3649f1fd70f71e103a818ee51a172870bd7d 100644 (file)
@@ -1,5 +1,6 @@
 const { expect } = require('expect')
 const {
+  DynamicClusterPool,
   DynamicThreadPool,
   FixedClusterPool,
   FixedThreadPool,
@@ -398,4 +399,21 @@ describe('Abstract pool test suite', () => {
     expect(poolBusy).toBe(numberOfWorkers + 1)
     await pool.destroy()
   })
+
+  it('Verify that multiple tasks worker is working', async () => {
+    const pool = new DynamicClusterPool(
+      numberOfWorkers,
+      numberOfWorkers * 2,
+      './tests/worker-files/cluster/testMultiTasksWorker.js'
+    )
+    const data = { n: 10 }
+    const result0 = await pool.execute(data)
+    expect(result0).toBe(false)
+    const result1 = await pool.execute(data, 'jsonIntegerSerialization')
+    expect(result1).toBe(false)
+    const result2 = await pool.execute(data, 'factorial')
+    expect(result2).toBe(3628800)
+    const result3 = await pool.execute(data, 'fibonacci')
+    expect(result3).toBe(89)
+  })
 })