Apply dependencies update
[poolifier.git] / tests / pools / abstract / abstract-pool.test.js
index bc7bdd1eb7932a90257bcb730f1e78f6dab4de43..80ebdb9e7e5a04b07f71f7878ed46318cbcd4fdb 100644 (file)
@@ -11,12 +11,14 @@ describe('Abstract pool test suite', () => {
   const workerNotFoundInTasksUsageMapError = new Error(
     'Worker could not be found in workers tasks usage map'
   )
-  class StubPoolWithWorkerTasksUsageMapClear extends FixedThreadPool {
+  class StubPoolWithRemoveAllWorker extends FixedThreadPool {
     removeAllWorker () {
+      this.workers = []
       this.workersTasksUsage.clear()
+      this.promiseMap.clear()
     }
   }
-  class StubPoolWithIsMainMethod extends FixedThreadPool {
+  class StubPoolWithIsMain extends FixedThreadPool {
     isMain () {
       return false
     }
@@ -25,7 +27,7 @@ describe('Abstract pool test suite', () => {
   it('Simulate pool creation from a non main thread/process', () => {
     expect(
       () =>
-        new StubPoolWithIsMainMethod(
+        new StubPoolWithIsMain(
           numberOfWorkers,
           './tests/worker-files/thread/testWorker.js',
           {
@@ -60,7 +62,9 @@ describe('Abstract pool test suite', () => {
       () =>
         new FixedClusterPool(-1, './tests/worker-files/cluster/testWorker.js')
     ).toThrowError(
-      new Error('Cannot instantiate a pool with a negative number of workers')
+      new RangeError(
+        'Cannot instantiate a pool with a negative number of workers'
+      )
     )
   })
 
@@ -69,7 +73,7 @@ describe('Abstract pool test suite', () => {
       () =>
         new FixedThreadPool(0.25, './tests/worker-files/thread/testWorker.js')
     ).toThrowError(
-      new Error(
+      new TypeError(
         'Cannot instantiate a pool with a non integer number of workers'
       )
     )
@@ -116,7 +120,7 @@ describe('Abstract pool test suite', () => {
   })
 
   it('Simulate worker not found during increaseWorkerRunningTasks', async () => {
-    const pool = new StubPoolWithWorkerTasksUsageMapClear(
+    const pool = new StubPoolWithRemoveAllWorker(
       numberOfWorkers,
       './tests/worker-files/cluster/testWorker.js'
     )
@@ -129,7 +133,7 @@ describe('Abstract pool test suite', () => {
   })
 
   it('Simulate worker not found during decreaseWorkerRunningTasks', async () => {
-    const pool = new StubPoolWithWorkerTasksUsageMapClear(
+    const pool = new StubPoolWithRemoveAllWorker(
       numberOfWorkers,
       './tests/worker-files/cluster/testWorker.js',
       {
@@ -145,7 +149,7 @@ describe('Abstract pool test suite', () => {
   })
 
   it('Simulate worker not found during stepWorkerRunTasks', async () => {
-    const pool = new StubPoolWithWorkerTasksUsageMapClear(
+    const pool = new StubPoolWithRemoveAllWorker(
       numberOfWorkers,
       './tests/worker-files/cluster/testWorker.js',
       {
@@ -161,7 +165,7 @@ describe('Abstract pool test suite', () => {
   })
 
   it('Simulate worker not found during updateWorkerTasksRunTime with strategy not requiring it', async () => {
-    const pool = new StubPoolWithWorkerTasksUsageMapClear(
+    const pool = new StubPoolWithRemoveAllWorker(
       numberOfWorkers,
       './tests/worker-files/cluster/testWorker.js',
       {
@@ -175,7 +179,7 @@ describe('Abstract pool test suite', () => {
   })
 
   it('Simulate worker not found during updateWorkerTasksRunTime with strategy requiring it', async () => {
-    const pool = new StubPoolWithWorkerTasksUsageMapClear(
+    const pool = new StubPoolWithRemoveAllWorker(
       numberOfWorkers,
       './tests/worker-files/cluster/testWorker.js',
       {