test: add more event emitter tests
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Sun, 24 Sep 2023 19:27:21 +0000 (21:27 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Sun, 24 Sep 2023 19:27:21 +0000 (21:27 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
tests/pools/cluster/fixed.test.js
tests/pools/thread/fixed.test.js

index 0994e9e903b247eb15f6eb2f8418afb102c36739..9b79f6ed8eed5f0b1e3f2802769a857c35b818ea 100644 (file)
@@ -97,8 +97,8 @@ describe('Fixed cluster pool test suite', () => {
   })
 
   it("Verify that 'busy' event is emitted", async () => {
-    expect(pool.emitter.eventNames()).toStrictEqual([])
     const promises = new Set()
+    expect(pool.emitter.eventNames()).toStrictEqual([])
     let poolBusy = 0
     pool.emitter.on(PoolEvents.busy, () => ++poolBusy)
     expect(pool.emitter.eventNames()).toStrictEqual([PoolEvents.busy])
index 42549b63c87376985f2665ed094c1b1cb2ebed25..acd944067c4e134b5f0a2f0dd31fa57bebed3ccd 100644 (file)
@@ -282,8 +282,13 @@ describe('Fixed thread pool test suite', () => {
 
   it('Shutdown test', async () => {
     const exitPromise = waitWorkerEvents(pool, 'exit', numberOfThreads)
+    expect(pool.emitter.eventNames()).toStrictEqual([PoolEvents.busy])
     let poolDestroy = 0
     pool.emitter.on(PoolEvents.destroy, () => ++poolDestroy)
+    expect(pool.emitter.eventNames()).toStrictEqual([
+      PoolEvents.busy,
+      PoolEvents.destroy
+    ])
     await pool.destroy()
     const numberOfExitEvents = await exitPromise
     expect(pool.started).toBe(false)