X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=tests%2Fpools%2Fcluster%2Ffixed.test.js;fp=tests%2Fpools%2Fcluster%2Ffixed.test.js;h=a5790db075f400b3ff4ff93dd6c0a01a3beb62fd;hb=94407def0f4cd4356982ce5144a6108aec9a1ff9;hp=3baaa98ad04831151e433856bdcacee5682338f9;hpb=e43b8c2da8ab98ffe61424613f5df7f8ae528986;p=poolifier.git diff --git a/tests/pools/cluster/fixed.test.js b/tests/pools/cluster/fixed.test.js index 3baaa98a..a5790db0 100644 --- a/tests/pools/cluster/fixed.test.js +++ b/tests/pools/cluster/fixed.test.js @@ -92,12 +92,14 @@ describe('Fixed cluster pool test suite', () => { expect(poolReady).toBe(1) }) - it("Verify that 'busy' event is emitted", () => { + it("Verify that 'busy' event is emitted", async () => { + const promises = new Set() let poolBusy = 0 pool.emitter.on(PoolEvents.busy, () => ++poolBusy) for (let i = 0; i < numberOfWorkers * 2; i++) { - pool.execute() + promises.add(pool.execute()) } + 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 numberOfWorkers + 1 times for a loop submitting up to numberOfWorkers * 2 tasks to the fixed pool. expect(poolBusy).toBe(numberOfWorkers + 1)