Merge dependabot/npm_and_yarn/examples/typescript/http-server-pool/express-hybrid...
[poolifier.git] / tests / pools / thread / fixed.test.js
index 065774ec695ef29a3c94dec2a96830d5f82cd68d..901c6665c7d0086bdf453466a7c74027a2c0e6d6 100644 (file)
@@ -301,16 +301,28 @@ describe('Fixed thread pool test suite', () => {
   })
 
   it('Should work even without opts in input', async () => {
-    const pool = new FixedThreadPool(
-      numberOfThreads,
-      './tests/worker-files/thread/testWorker.js'
-    )
+    const workerFilePath = './tests/worker-files/thread/testWorker.js'
+    const pool = new FixedThreadPool(numberOfThreads, workerFilePath)
     const res = await pool.execute()
     expect(res).toStrictEqual({ ok: 1 })
     // We need to clean up the resources after our test
     await pool.destroy()
   })
 
+  it('Verify destroyWorkerNode()', async () => {
+    const workerFilePath = './tests/worker-files/thread/testWorker.js'
+    const pool = new FixedThreadPool(numberOfThreads, workerFilePath)
+    const workerNodeKey = 0
+    let exitEvent = 0
+    pool.workerNodes[workerNodeKey].worker.on('exit', () => {
+      ++exitEvent
+    })
+    await expect(pool.destroyWorkerNode(workerNodeKey)).resolves.toBeUndefined()
+    expect(exitEvent).toBe(1)
+    expect(pool.workerNodes.length).toBe(numberOfThreads - 1)
+    await pool.destroy()
+  })
+
   it('Verify that a pool with zero worker fails', async () => {
     expect(
       () => new FixedThreadPool(0, './tests/worker-files/thread/testWorker.js')