fix: fix pool statuses semantic
[poolifier.git] / tests / pools / cluster / fixed.test.js
index 6daec1400dbc9dc0fdb921d6b25b53dd9d751eab..f71529a911949f285d0c54ebd8be5b27d67d0e3d 100644 (file)
@@ -3,7 +3,7 @@ const { FixedClusterPool, PoolEvents } = require('../../../lib')
 const { WorkerFunctions } = require('../../test-types')
 const { waitPoolEvents, waitWorkerEvents } = require('../../test-utils')
 
-describe('Fixed cluster pool test suite', async () => {
+describe('Fixed cluster pool test suite', () => {
   const numberOfWorkers = 6
   const pool = new FixedClusterPool(
     numberOfWorkers,
@@ -12,9 +12,6 @@ describe('Fixed cluster pool test suite', async () => {
       errorHandler: e => console.error(e)
     }
   )
-  let poolReady = 0
-  pool.emitter.on(PoolEvents.ready, () => ++poolReady)
-  await waitPoolEvents(pool, PoolEvents.ready, 1)
   const queuePool = new FixedClusterPool(
     numberOfWorkers,
     './tests/worker-files/cluster/testWorker.js',
@@ -81,10 +78,20 @@ describe('Fixed cluster pool test suite', async () => {
   })
 
   it("Verify that 'ready' event is emitted", async () => {
+    const pool1 = new FixedClusterPool(
+      numberOfWorkers,
+      './tests/worker-files/cluster/testWorker.js',
+      {
+        errorHandler: e => console.error(e)
+      }
+    )
+    let poolReady = 0
+    pool1.emitter.on(PoolEvents.ready, () => ++poolReady)
+    await waitPoolEvents(pool1, PoolEvents.ready, 1)
     expect(poolReady).toBe(1)
   })
 
-  it("Verify that 'busy' event is emitted", async () => {
+  it("Verify that 'busy' event is emitted", () => {
     let poolBusy = 0
     pool.emitter.on(PoolEvents.busy, () => ++poolBusy)
     for (let i = 0; i < numberOfWorkers * 2; i++) {
@@ -154,6 +161,7 @@ describe('Fixed cluster pool test suite', async () => {
     expect(typeof inError === 'string').toBe(true)
     expect(inError).toBe('Error Message from ClusterWorker')
     expect(taskError).toStrictEqual({
+      name: 'default',
       message: 'Error Message from ClusterWorker',
       data
     })
@@ -180,6 +188,7 @@ describe('Fixed cluster pool test suite', async () => {
     expect(typeof inError === 'string').toBe(true)
     expect(inError).toBe('Error Message from ClusterWorker:async')
     expect(taskError).toStrictEqual({
+      name: 'default',
       message: 'Error Message from ClusterWorker:async',
       data
     })