test: improve UTs
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Mon, 28 Aug 2023 10:19:23 +0000 (12:19 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Mon, 28 Aug 2023 10:19:23 +0000 (12:19 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
tests/pools/abstract/abstract-pool.test.js
tests/pools/cluster/dynamic.test.js
tests/pools/cluster/fixed.test.js
tests/pools/thread/dynamic.test.js
tests/pools/thread/fixed.test.js
tests/utils.test.js

index 5435565a9419ede3b7f7222266c1dda03e416438..be745d94ce5e4b10c89012846f6f67d85899abc0 100644 (file)
@@ -53,7 +53,6 @@ describe('Abstract pool test suite', () => {
     expect(pool.starting).toBe(false)
     expect(pool.started).toBe(true)
     await pool.destroy()
-    expect(pool.started).toBe(false)
   })
 
   it('Verify that filePath is checked', () => {
index 44d543ec5c83c032241a988555f7bccdabbc8812..8f4d2c9ad2e6f86bced3d9a8902cb551ec7a191e 100644 (file)
@@ -61,6 +61,8 @@ describe('Dynamic cluster pool test suite', () => {
     pool.emitter.on(PoolEvents.destroy, () => ++poolDestroy)
     await pool.destroy()
     const numberOfExitEvents = await exitPromise
+    expect(pool.started).toBe(false)
+    expect(pool.workerNodes.length).toBe(0)
     expect(numberOfExitEvents).toBe(min)
     expect(poolDestroy).toBe(1)
   })
index 04af63846d2a30125f92eaae3311b237cab2b8a4..6edfcd67b8c53517b7f4d635b3738ca43131a76b 100644 (file)
@@ -246,6 +246,8 @@ describe('Fixed cluster pool test suite', () => {
     pool.emitter.on(PoolEvents.destroy, () => ++poolDestroy)
     await pool.destroy()
     const numberOfExitEvents = await exitPromise
+    expect(pool.started).toBe(false)
+    expect(pool.workerNodes.length).toBe(0)
     expect(numberOfExitEvents).toBe(numberOfWorkers)
     expect(poolDestroy).toBe(1)
   })
index 2f3f4510cdc9567bdceb7a3951a606afb0168909..e30099dd4f890097e5ee705662273ee1e04ce97e 100644 (file)
@@ -61,6 +61,8 @@ describe('Dynamic thread pool test suite', () => {
     pool.emitter.on(PoolEvents.destroy, () => ++poolDestroy)
     await pool.destroy()
     const numberOfExitEvents = await exitPromise
+    expect(pool.started).toBe(false)
+    expect(pool.workerNodes.length).toBe(0)
     expect(numberOfExitEvents).toBe(min)
     expect(poolDestroy).toBe(1)
   })
index 09363b84e450f5aa201c2e3428b5003af9653ceb..065774ec695ef29a3c94dec2a96830d5f82cd68d 100644 (file)
@@ -276,6 +276,8 @@ describe('Fixed thread pool test suite', () => {
     pool.emitter.on(PoolEvents.destroy, () => ++poolDestroy)
     await pool.destroy()
     const numberOfExitEvents = await exitPromise
+    expect(pool.started).toBe(false)
+    expect(pool.workerNodes.length).toBe(0)
     expect(numberOfExitEvents).toBe(numberOfThreads)
     expect(poolDestroy).toBe(1)
   })
index 2c41b6920657944f9c498329233b470f2b99ce43..57bd2611ba9d517a0af1a458301b8fe090c633a9 100644 (file)
@@ -45,7 +45,7 @@ describe('Utils test suite', () => {
     expect(getWorkerId(clusterWorker)).toBe(clusterWorker.id)
   })
 
-  it.skip('Verify sleep() behavior', async () => {
+  it('Verify sleep() behavior', async () => {
     const start = performance.now()
     await sleep(1000)
     const elapsed = performance.now() - start