Fix pool execute promises fullfilment in tests
[poolifier.git] / tests / pools / thread / fixed.test.js
index 763e3f881dbc066d5b868e981608d1730a3668e7..f89977b3a5be536f71972c2db66e2837eac4f3b4 100644 (file)
@@ -74,6 +74,7 @@ describe('Fixed thread pool test suite', () => {
     for (let i = 0; i < numberOfThreads * 2; i++) {
       promises.push(pool.execute({ test: 'test' }))
     }
+    await Promise.all(promises)
     // The `busy` event is triggered when the number of submitted tasks at once reach the number of fixed pool workers.
     // So in total numberOfThreads + 1 times for a loop submitting up to numberOfThreads * 2 tasks to the fixed pool.
     expect(poolBusy).toBe(numberOfThreads + 1)
@@ -103,6 +104,7 @@ describe('Fixed thread pool test suite', () => {
     expect(inError).toBeInstanceOf(Error)
     expect(inError.message).toBeDefined()
     expect(typeof inError.message === 'string').toBe(true)
+    expect(inError.message).toBe('Error Message from ThreadWorker')
   })
 
   it('Verify that error handling is working properly:async', async () => {
@@ -117,6 +119,7 @@ describe('Fixed thread pool test suite', () => {
     expect(inError).toBeInstanceOf(Error)
     expect(inError.message).toBeDefined()
     expect(typeof inError.message === 'string').toBe(true)
+    expect(inError.message).toBe('Error Message from ThreadWorker:async')
   })
 
   it('Verify that async function is working properly', async () => {