X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=tests%2Fpools%2Fthread%2Ffixed.test.js;h=aed2b3c193ffe90977fa9f853aa670f0eaff51b5;hb=4a581fcdc17b63ec445ce2b8b85a80ffe4961159;hp=7e7a74cfbdcdf226523eb613d0aa5b72d54266b0;hpb=29ee7e9a3f325f87d889ef09ffc1eea4916a782f;p=poolifier.git diff --git a/tests/pools/thread/fixed.test.js b/tests/pools/thread/fixed.test.js index 7e7a74cf..aed2b3c1 100644 --- a/tests/pools/thread/fixed.test.js +++ b/tests/pools/thread/fixed.test.js @@ -65,11 +65,11 @@ describe('Fixed thread pool test suite', () => { let result = await pool.execute({ function: WorkerFunctions.fibonacci }) - expect(result).toBe(false) + expect(result).toBe(121393) result = await pool.execute({ function: WorkerFunctions.factorial }) - expect(result).toBe(false) + expect(result).toBe(9.33262154439441e157) }) it('Verify that is possible to invoke the execute() method without input', async () => { @@ -100,7 +100,7 @@ describe('Fixed thread pool test suite', () => { queuePool.opts.tasksQueueOptions.concurrency ) expect(workerNode.tasksUsage.run).toBe(0) - expect(workerNode.tasksQueue.size()).toBeGreaterThan(0) + expect(workerNode.tasksQueue.size).toBeGreaterThan(0) } expect(queuePool.numberOfRunningTasks).toBe(numberOfThreads) expect(queuePool.numberOfQueuedTasks).toBe( @@ -110,7 +110,7 @@ describe('Fixed thread pool test suite', () => { for (const workerNode of queuePool.workerNodes) { expect(workerNode.tasksUsage.running).toBe(0) expect(workerNode.tasksUsage.run).toBeGreaterThan(0) - expect(workerNode.tasksQueue.size()).toBe(0) + expect(workerNode.tasksQueue.size).toBe(0) } promises.clear() }) @@ -139,6 +139,11 @@ describe('Fixed thread pool test suite', () => { expect(inError.message).toBeDefined() expect(typeof inError.message === 'string').toBe(true) expect(inError.message).toBe('Error Message from ThreadWorker') + expect( + errorPool.workerNodes.some( + workerNode => workerNode.tasksUsage.error === 1 + ) + ).toBe(true) }) it('Verify that error handling is working properly:async', async () => { @@ -154,6 +159,11 @@ describe('Fixed thread pool test suite', () => { expect(inError.message).toBeDefined() expect(typeof inError.message === 'string').toBe(true) expect(inError.message).toBe('Error Message from ThreadWorker:async') + expect( + asyncErrorPool.workerNodes.some( + workerNode => workerNode.tasksUsage.error === 1 + ) + ).toBe(true) }) it('Verify that async function is working properly', async () => {