X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=tests%2Fpools%2Fthread%2Ffixed.test.js;h=2a7d005b3dcd6d88a53e4e53e1d2216c55483de4;hb=85a3f8a7b3087e7240c1d307ba6dd78c05883f83;hp=755ccf4d4fa2aa12b0621344d1010af377431248;hpb=e901162fa610e2af305aac504549580b2de48cab;p=poolifier.git diff --git a/tests/pools/thread/fixed.test.js b/tests/pools/thread/fixed.test.js index 755ccf4d..2a7d005b 100644 --- a/tests/pools/thread/fixed.test.js +++ b/tests/pools/thread/fixed.test.js @@ -1,5 +1,6 @@ const expect = require('expect') const { FixedThreadPool } = require('../../../lib/index') +const TestUtils = require('../../test-utils') const numberOfThreads = 10 const maxTasks = 400 const pool = new FixedThreadPool( @@ -93,26 +94,10 @@ describe('Fixed thread pool test suite ', () => { }) it('Shutdown test', async () => { - let closedThreads = 0 - pool.workers.forEach(w => { - w.on('exit', () => { - closedThreads++ - }) - }) + const exitPromise = TestUtils.waitExits(pool, numberOfThreads) await pool.destroy() - expect(closedThreads).toBe(numberOfThreads) - }) - - it('Validations test', () => { - let error - try { - const pool1 = new FixedThreadPool() - console.log(pool1) - } catch (e) { - error = e - } - expect(error).toBeTruthy() - expect(error.message).toBeTruthy() + const res = await exitPromise + expect(res).toBe(numberOfThreads) }) it('Should work even without opts in input', async () => {