test: toThrowError() -> toThrow()
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Sun, 8 Oct 2023 14:00:59 +0000 (16:00 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Sun, 8 Oct 2023 14:00:59 +0000 (16:00 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
tests/circular-array.test.mjs
tests/pools/abstract-pool.test.mjs
tests/pools/cluster/dynamic.test.mjs
tests/pools/cluster/fixed.test.mjs
tests/pools/selection-strategies/selection-strategies.test.mjs
tests/pools/selection-strategies/worker-choice-strategy-context.test.mjs
tests/pools/thread/dynamic.test.mjs
tests/pools/thread/fixed.test.mjs
tests/pools/worker-node.test.mjs
tests/worker/abstract-worker.test.mjs

index 0e13a8c32098a19a26c80dc26e2195ad7ee6a214..dfa1b53c8e01e73a93ce2cc1f09e5c99d336bcba 100644 (file)
@@ -30,13 +30,13 @@ describe('Circular array test suite', () => {
   })
 
   it('Verify that circular array size is valid at instance creation', () => {
-    expect(() => new CircularArray(0.25)).toThrowError(
+    expect(() => new CircularArray(0.25)).toThrow(
       new TypeError('Invalid circular array size: 0.25 is not a safe integer')
     )
-    expect(() => new CircularArray(-1)).toThrowError(
+    expect(() => new CircularArray(-1)).toThrow(
       new RangeError('Invalid circular array size: -1 < 0')
     )
-    expect(() => new CircularArray(Number.MAX_SAFE_INTEGER + 1)).toThrowError(
+    expect(() => new CircularArray(Number.MAX_SAFE_INTEGER + 1)).toThrow(
       new TypeError(
         `Invalid circular array size: ${
           Number.MAX_SAFE_INTEGER + 1
@@ -116,15 +116,15 @@ describe('Circular array test suite', () => {
   })
 
   it('Verify that circular array resize works as intended', () => {
-    expect(() => new CircularArray().resize(0.25)).toThrowError(
+    expect(() => new CircularArray().resize(0.25)).toThrow(
       new TypeError('Invalid circular array size: 0.25 is not a safe integer')
     )
-    expect(() => new CircularArray().resize(-1)).toThrowError(
+    expect(() => new CircularArray().resize(-1)).toThrow(
       new RangeError('Invalid circular array size: -1 < 0')
     )
     expect(() =>
       new CircularArray().resize(Number.MAX_SAFE_INTEGER + 1)
-    ).toThrowError(
+    ).toThrow(
       new TypeError(
         `Invalid circular array size: ${
           Number.MAX_SAFE_INTEGER + 1
index 765a2b0d1553febb95feb3fd36307e6f2eacda66..8c0319e7c04bbad87b5531e16d2b2a1f3726d28c 100644 (file)
@@ -48,7 +48,7 @@ describe('Abstract pool test suite', () => {
             errorHandler: e => console.error(e)
           }
         )
-    ).toThrowError(
+    ).toThrow(
       new Error(
         'Cannot start a pool from a worker with the same type as the pool'
       )
@@ -66,12 +66,12 @@ describe('Abstract pool test suite', () => {
   })
 
   it('Verify that filePath is checked', () => {
-    expect(() => new FixedThreadPool(numberOfWorkers)).toThrowError(
+    expect(() => new FixedThreadPool(numberOfWorkers)).toThrow(
       new Error("Cannot find the worker file 'undefined'")
     )
     expect(
       () => new FixedThreadPool(numberOfWorkers, './dummyWorker.ts')
-    ).toThrowError(new Error("Cannot find the worker file './dummyWorker.ts'"))
+    ).toThrow(new Error("Cannot find the worker file './dummyWorker.ts'"))
   })
 
   it('Verify that numberOfWorkers is checked', () => {
@@ -81,7 +81,7 @@ describe('Abstract pool test suite', () => {
           undefined,
           './tests/worker-files/thread/testWorker.mjs'
         )
-    ).toThrowError(
+    ).toThrow(
       new Error(
         'Cannot instantiate a pool without specifying the number of workers'
       )
@@ -92,7 +92,7 @@ describe('Abstract pool test suite', () => {
     expect(
       () =>
         new FixedClusterPool(-1, './tests/worker-files/cluster/testWorker.js')
-    ).toThrowError(
+    ).toThrow(
       new RangeError(
         'Cannot instantiate a pool with a negative number of workers'
       )
@@ -103,7 +103,7 @@ describe('Abstract pool test suite', () => {
     expect(
       () =>
         new FixedThreadPool(0.25, './tests/worker-files/thread/testWorker.mjs')
-    ).toThrowError(
+    ).toThrow(
       new TypeError(
         'Cannot instantiate a pool with a non safe integer number of workers'
       )
@@ -118,7 +118,7 @@ describe('Abstract pool test suite', () => {
           undefined,
           './tests/worker-files/cluster/testWorker.js'
         )
-    ).toThrowError(
+    ).toThrow(
       new TypeError(
         'Cannot instantiate a dynamic pool without specifying the maximum pool size'
       )
@@ -130,7 +130,7 @@ describe('Abstract pool test suite', () => {
           1,
           './tests/worker-files/thread/testWorker.mjs'
         )
-    ).toThrowError(
+    ).toThrow(
       new TypeError(
         'Cannot instantiate a pool with a non safe integer number of workers'
       )
@@ -142,7 +142,7 @@ describe('Abstract pool test suite', () => {
           0.5,
           './tests/worker-files/cluster/testWorker.js'
         )
-    ).toThrowError(
+    ).toThrow(
       new TypeError(
         'Cannot instantiate a dynamic pool with a non safe integer maximum pool size'
       )
@@ -154,7 +154,7 @@ describe('Abstract pool test suite', () => {
           1,
           './tests/worker-files/thread/testWorker.mjs'
         )
-    ).toThrowError(
+    ).toThrow(
       new RangeError(
         'Cannot instantiate a dynamic pool with a maximum pool size inferior to the minimum pool size'
       )
@@ -166,7 +166,7 @@ describe('Abstract pool test suite', () => {
           0,
           './tests/worker-files/thread/testWorker.mjs'
         )
-    ).toThrowError(
+    ).toThrow(
       new RangeError(
         'Cannot instantiate a dynamic pool with a maximum pool size equal to zero'
       )
@@ -178,7 +178,7 @@ describe('Abstract pool test suite', () => {
           1,
           './tests/worker-files/cluster/testWorker.js'
         )
-    ).toThrowError(
+    ).toThrow(
       new RangeError(
         'Cannot instantiate a dynamic pool with a minimum pool size equal to the maximum pool size. Use a fixed pool instead'
       )
@@ -295,9 +295,7 @@ describe('Abstract pool test suite', () => {
             workerChoiceStrategy: 'invalidStrategy'
           }
         )
-    ).toThrowError(
-      new Error("Invalid worker choice strategy 'invalidStrategy'")
-    )
+    ).toThrow(new Error("Invalid worker choice strategy 'invalidStrategy'"))
     expect(
       () =>
         new FixedThreadPool(
@@ -309,7 +307,7 @@ describe('Abstract pool test suite', () => {
             }
           }
         )
-    ).toThrowError(
+    ).toThrow(
       new TypeError(
         'Invalid worker choice strategy options: retries must be an integer'
       )
@@ -325,7 +323,7 @@ describe('Abstract pool test suite', () => {
             }
           }
         )
-    ).toThrowError(
+    ).toThrow(
       new RangeError(
         "Invalid worker choice strategy options: retries '-1' must be greater or equal than zero"
       )
@@ -339,7 +337,7 @@ describe('Abstract pool test suite', () => {
             workerChoiceStrategyOptions: { weights: {} }
           }
         )
-    ).toThrowError(
+    ).toThrow(
       new Error(
         'Invalid worker choice strategy options: must have a weight for each worker node'
       )
@@ -353,7 +351,7 @@ describe('Abstract pool test suite', () => {
             workerChoiceStrategyOptions: { measurement: 'invalidMeasurement' }
           }
         )
-    ).toThrowError(
+    ).toThrow(
       new Error(
         "Invalid worker choice strategy options: invalid measurement 'invalidMeasurement'"
       )
@@ -368,7 +366,7 @@ describe('Abstract pool test suite', () => {
             tasksQueueOptions: 'invalidTasksQueueOptions'
           }
         )
-    ).toThrowError(
+    ).toThrow(
       new TypeError('Invalid tasks queue options: must be a plain object')
     )
     expect(
@@ -381,7 +379,7 @@ describe('Abstract pool test suite', () => {
             tasksQueueOptions: { concurrency: 0 }
           }
         )
-    ).toThrowError(
+    ).toThrow(
       new RangeError(
         'Invalid worker node tasks concurrency: 0 is a negative integer or zero'
       )
@@ -396,7 +394,7 @@ describe('Abstract pool test suite', () => {
             tasksQueueOptions: { concurrency: -1 }
           }
         )
-    ).toThrowError(
+    ).toThrow(
       new RangeError(
         'Invalid worker node tasks concurrency: -1 is a negative integer or zero'
       )
@@ -411,7 +409,7 @@ describe('Abstract pool test suite', () => {
             tasksQueueOptions: { concurrency: 0.2 }
           }
         )
-    ).toThrowError(
+    ).toThrow(
       new TypeError('Invalid worker node tasks concurrency: must be an integer')
     )
     expect(
@@ -424,7 +422,7 @@ describe('Abstract pool test suite', () => {
             tasksQueueOptions: { size: 0 }
           }
         )
-    ).toThrowError(
+    ).toThrow(
       new RangeError(
         'Invalid worker node tasks queue size: 0 is a negative integer or zero'
       )
@@ -439,7 +437,7 @@ describe('Abstract pool test suite', () => {
             tasksQueueOptions: { size: -1 }
           }
         )
-    ).toThrowError(
+    ).toThrow(
       new RangeError(
         'Invalid worker node tasks queue size: -1 is a negative integer or zero'
       )
@@ -454,7 +452,7 @@ describe('Abstract pool test suite', () => {
             tasksQueueOptions: { size: 0.2 }
           }
         )
-    ).toThrowError(
+    ).toThrow(
       new TypeError('Invalid worker node tasks queue size: must be an integer')
     )
   })
@@ -595,7 +593,7 @@ describe('Abstract pool test suite', () => {
     })
     expect(() =>
       pool.setWorkerChoiceStrategyOptions('invalidWorkerChoiceStrategyOptions')
-    ).toThrowError(
+    ).toThrow(
       new TypeError(
         'Invalid worker choice strategy options: must be a plain object'
       )
@@ -604,28 +602,24 @@ describe('Abstract pool test suite', () => {
       pool.setWorkerChoiceStrategyOptions({
         retries: 'invalidChoiceRetries'
       })
-    ).toThrowError(
+    ).toThrow(
       new TypeError(
         'Invalid worker choice strategy options: retries must be an integer'
       )
     )
-    expect(() =>
-      pool.setWorkerChoiceStrategyOptions({ retries: -1 })
-    ).toThrowError(
+    expect(() => pool.setWorkerChoiceStrategyOptions({ retries: -1 })).toThrow(
       new RangeError(
         "Invalid worker choice strategy options: retries '-1' must be greater or equal than zero"
       )
     )
-    expect(() =>
-      pool.setWorkerChoiceStrategyOptions({ weights: {} })
-    ).toThrowError(
+    expect(() => pool.setWorkerChoiceStrategyOptions({ weights: {} })).toThrow(
       new Error(
         'Invalid worker choice strategy options: must have a weight for each worker node'
       )
     )
     expect(() =>
       pool.setWorkerChoiceStrategyOptions({ measurement: 'invalidMeasurement' })
-    ).toThrowError(
+    ).toThrow(
       new Error(
         "Invalid worker choice strategy options: invalid measurement 'invalidMeasurement'"
       )
@@ -734,35 +728,33 @@ describe('Abstract pool test suite', () => {
       expect(workerNode.onEmptyQueue).toBeInstanceOf(Function)
       expect(workerNode.onBackPressure).toBeInstanceOf(Function)
     }
-    expect(() =>
-      pool.setTasksQueueOptions('invalidTasksQueueOptions')
-    ).toThrowError(
+    expect(() => pool.setTasksQueueOptions('invalidTasksQueueOptions')).toThrow(
       new TypeError('Invalid tasks queue options: must be a plain object')
     )
-    expect(() => pool.setTasksQueueOptions({ concurrency: 0 })).toThrowError(
+    expect(() => pool.setTasksQueueOptions({ concurrency: 0 })).toThrow(
       new RangeError(
         'Invalid worker node tasks concurrency: 0 is a negative integer or zero'
       )
     )
-    expect(() => pool.setTasksQueueOptions({ concurrency: -1 })).toThrowError(
+    expect(() => pool.setTasksQueueOptions({ concurrency: -1 })).toThrow(
       new RangeError(
         'Invalid worker node tasks concurrency: -1 is a negative integer or zero'
       )
     )
-    expect(() => pool.setTasksQueueOptions({ concurrency: 0.2 })).toThrowError(
+    expect(() => pool.setTasksQueueOptions({ concurrency: 0.2 })).toThrow(
       new TypeError('Invalid worker node tasks concurrency: must be an integer')
     )
-    expect(() => pool.setTasksQueueOptions({ size: 0 })).toThrowError(
+    expect(() => pool.setTasksQueueOptions({ size: 0 })).toThrow(
       new RangeError(
         'Invalid worker node tasks queue size: 0 is a negative integer or zero'
       )
     )
-    expect(() => pool.setTasksQueueOptions({ size: -1 })).toThrowError(
+    expect(() => pool.setTasksQueueOptions({ size: -1 })).toThrow(
       new RangeError(
         'Invalid worker node tasks queue size: -1 is a negative integer or zero'
       )
     )
-    expect(() => pool.setTasksQueueOptions({ size: 0.2 })).toThrowError(
+    expect(() => pool.setTasksQueueOptions({ size: 0.2 })).toThrow(
       new TypeError('Invalid worker node tasks queue size: must be an integer')
     )
     await pool.destroy()
@@ -918,7 +910,7 @@ describe('Abstract pool test suite', () => {
     expect(pool.info.started).toBe(false)
     expect(pool.info.ready).toBe(false)
     expect(pool.workerNodes).toStrictEqual([])
-    await expect(pool.execute()).rejects.toThrowError(
+    await expect(pool.execute()).rejects.toThrow(
       new Error('Cannot execute a task on not started pool')
     )
     pool.start()
@@ -936,20 +928,20 @@ describe('Abstract pool test suite', () => {
       numberOfWorkers,
       './tests/worker-files/cluster/testWorker.js'
     )
-    await expect(pool.execute(undefined, 0)).rejects.toThrowError(
+    await expect(pool.execute(undefined, 0)).rejects.toThrow(
       new TypeError('name argument must be a string')
     )
-    await expect(pool.execute(undefined, '')).rejects.toThrowError(
+    await expect(pool.execute(undefined, '')).rejects.toThrow(
       new TypeError('name argument must not be an empty string')
     )
-    await expect(pool.execute(undefined, undefined, {})).rejects.toThrowError(
+    await expect(pool.execute(undefined, undefined, {})).rejects.toThrow(
       new TypeError('transferList argument must be an array')
     )
     await expect(pool.execute(undefined, 'unknown')).rejects.toBe(
       "Task function 'unknown' not found"
     )
     await pool.destroy()
-    await expect(pool.execute()).rejects.toThrowError(
+    await expect(pool.execute()).rejects.toThrow(
       new Error('Cannot execute a task on not started pool')
     )
   })
@@ -1300,18 +1292,18 @@ describe('Abstract pool test suite', () => {
     await waitPoolEvents(dynamicThreadPool, PoolEvents.ready, 1)
     await expect(
       dynamicThreadPool.addTaskFunction(0, () => {})
-    ).rejects.toThrowError(new TypeError('name argument must be a string'))
+    ).rejects.toThrow(new TypeError('name argument must be a string'))
     await expect(
       dynamicThreadPool.addTaskFunction('', () => {})
-    ).rejects.toThrowError(
+    ).rejects.toThrow(
       new TypeError('name argument must not be an empty string')
     )
-    await expect(
-      dynamicThreadPool.addTaskFunction('test', 0)
-    ).rejects.toThrowError(new TypeError('fn argument must be a function'))
-    await expect(
-      dynamicThreadPool.addTaskFunction('test', '')
-    ).rejects.toThrowError(new TypeError('fn argument must be a function'))
+    await expect(dynamicThreadPool.addTaskFunction('test', 0)).rejects.toThrow(
+      new TypeError('fn argument must be a function')
+    )
+    await expect(dynamicThreadPool.addTaskFunction('test', '')).rejects.toThrow(
+      new TypeError('fn argument must be a function')
+    )
     expect(dynamicThreadPool.listTaskFunctionNames()).toStrictEqual([
       DEFAULT_TASK_NAME,
       'test'
@@ -1373,9 +1365,7 @@ describe('Abstract pool test suite', () => {
       DEFAULT_TASK_NAME,
       'test'
     ])
-    await expect(
-      dynamicThreadPool.removeTaskFunction('test')
-    ).rejects.toThrowError(
+    await expect(dynamicThreadPool.removeTaskFunction('test')).rejects.toThrow(
       new Error('Cannot remove a task function not handled on the pool side')
     )
     const echoTaskFunction = data => {
@@ -1438,23 +1428,21 @@ describe('Abstract pool test suite', () => {
       './tests/worker-files/thread/testMultipleTaskFunctionsWorker.mjs'
     )
     await waitPoolEvents(dynamicThreadPool, PoolEvents.ready, 1)
-    await expect(
-      dynamicThreadPool.setDefaultTaskFunction(0)
-    ).rejects.toThrowError(
+    await expect(dynamicThreadPool.setDefaultTaskFunction(0)).rejects.toThrow(
       new Error(
         "Task function operation 'default' failed on worker 31 with error: 'TypeError: name parameter is not a string'"
       )
     )
     await expect(
       dynamicThreadPool.setDefaultTaskFunction(DEFAULT_TASK_NAME)
-    ).rejects.toThrowError(
+    ).rejects.toThrow(
       new Error(
         "Task function operation 'default' failed on worker 31 with error: 'Error: Cannot set the default task function reserved name as the default task function'"
       )
     )
     await expect(
       dynamicThreadPool.setDefaultTaskFunction('unknown')
-    ).rejects.toThrowError(
+    ).rejects.toThrow(
       new Error(
         "Task function operation 'default' failed on worker 31 with error: 'Error: Cannot set the default task function to a non-existing task function'"
       )
index 93dcc7fad89e8adb942ce667d99e21ebb2a91e88..afc013f165a7d2416b39c1061d329710cd183304 100644 (file)
@@ -73,7 +73,7 @@ describe('Dynamic cluster pool test suite', () => {
   })
 
   it('Validation of inputs test', () => {
-    expect(() => new DynamicClusterPool(min)).toThrowError(
+    expect(() => new DynamicClusterPool(min)).toThrow(
       "Cannot find the worker file 'undefined'"
     )
   })
index 4471f51309c39cdb056203aa97d0c03205bb9043..426a64f00d29e051985c93371f34c9fe0ea4c86e 100644 (file)
@@ -322,6 +322,6 @@ describe('Fixed cluster pool test suite', () => {
     expect(
       () =>
         new FixedClusterPool(0, './tests/worker-files/cluster/testWorker.js')
-    ).toThrowError('Cannot instantiate a fixed pool with zero worker')
+    ).toThrow('Cannot instantiate a fixed pool with zero worker')
   })
 })
index e0eec68b714a3152e49ed6bfd3e26d50a06e8584..601d66c825680514f4092498decb7e06161e8c1d 100644 (file)
@@ -2300,6 +2300,6 @@ describe('Selection strategies test suite', () => {
           './tests/worker-files/thread/testWorker.mjs',
           { workerChoiceStrategy: 'UNKNOWN_STRATEGY' }
         )
-    ).toThrowError("Invalid worker choice strategy 'UNKNOWN_STRATEGY'")
+    ).toThrow("Invalid worker choice strategy 'UNKNOWN_STRATEGY'")
   })
 })
index dc898e4ff04cd8ccb554a1215191896354757928..2a5f914e9d89a3bf40828f3ef198482612422a0c 100644 (file)
@@ -98,14 +98,14 @@ describe('Worker choice strategy context test suite', () => {
       workerChoiceStrategyContext.workerChoiceStrategy,
       workerChoiceStrategyUndefinedStub
     )
-    expect(() => workerChoiceStrategyContext.execute()).toThrowError(
+    expect(() => workerChoiceStrategyContext.execute()).toThrow(
       new Error('Worker node key chosen is null or undefined after 6 retries')
     )
     workerChoiceStrategyContext.workerChoiceStrategies.set(
       workerChoiceStrategyContext.workerChoiceStrategy,
       workerChoiceStrategyNullStub
     )
-    expect(() => workerChoiceStrategyContext.execute()).toThrowError(
+    expect(() => workerChoiceStrategyContext.execute()).toThrow(
       new Error('Worker node key chosen is null or undefined after 6 retries')
     )
   })
index c31e141c091b52c7ff2050253051eb8fd2e68092..4fcd2d1b039c3c27e3c3308399c25e2c94a1867c 100644 (file)
@@ -73,7 +73,7 @@ describe('Dynamic thread pool test suite', () => {
   })
 
   it('Validation of inputs test', () => {
-    expect(() => new DynamicThreadPool(min)).toThrowError(
+    expect(() => new DynamicThreadPool(min)).toThrow(
       "Cannot find the worker file 'undefined'"
     )
   })
index fd7f5935697d9e2074d1f9734b6b2345159e9775..214913d4b5f89e7b92a33fae5eb912852a80eb1f 100644 (file)
@@ -341,6 +341,6 @@ describe('Fixed thread pool test suite', () => {
   it('Verify that a pool with zero worker fails', () => {
     expect(
       () => new FixedThreadPool(0, './tests/worker-files/thread/testWorker.mjs')
-    ).toThrowError('Cannot instantiate a fixed pool with zero worker')
+    ).toThrow('Cannot instantiate a fixed pool with zero worker')
   })
 })
index a847e4fedec5374713f514900beed3afb8097e67..d524c464ee2d92139bb243b22b5b93749711e451 100644 (file)
@@ -14,32 +14,32 @@ describe('Worker node test suite', () => {
   const clusterWorkerNode = new WorkerNode(clusterWorker, 12)
 
   it('Worker node instantiation', () => {
-    expect(() => new WorkerNode()).toThrowError(
+    expect(() => new WorkerNode()).toThrow(
       new TypeError('Cannot construct a worker node without a worker')
     )
-    expect(() => new WorkerNode(threadWorker)).toThrowError(
+    expect(() => new WorkerNode(threadWorker)).toThrow(
       new TypeError(
         'Cannot construct a worker node without a tasks queue back pressure size'
       )
     )
     expect(
       () => new WorkerNode(threadWorker, 'invalidTasksQueueBackPressureSize')
-    ).toThrowError(
+    ).toThrow(
       new TypeError(
         'Cannot construct a worker node with a tasks queue back pressure size that is not an integer'
       )
     )
-    expect(() => new WorkerNode(threadWorker, 0.2)).toThrowError(
+    expect(() => new WorkerNode(threadWorker, 0.2)).toThrow(
       new TypeError(
         'Cannot construct a worker node with a tasks queue back pressure size that is not an integer'
       )
     )
-    expect(() => new WorkerNode(threadWorker, 0)).toThrowError(
+    expect(() => new WorkerNode(threadWorker, 0)).toThrow(
       new RangeError(
         'Cannot construct a worker node with a tasks queue back pressure size that is not a positive integer'
       )
     )
-    expect(() => new WorkerNode(threadWorker, -1)).toThrowError(
+    expect(() => new WorkerNode(threadWorker, -1)).toThrow(
       new RangeError(
         'Cannot construct a worker node with a tasks queue back pressure size that is not a positive integer'
       )
@@ -134,7 +134,7 @@ describe('Worker node test suite', () => {
   it('Worker node getTaskFunctionWorkerUsage()', () => {
     expect(() =>
       threadWorkerNode.getTaskFunctionWorkerUsage('invalidTaskFunction')
-    ).toThrowError(
+    ).toThrow(
       new TypeError(
         "Cannot get task function worker usage for task function name 'invalidTaskFunction' when task function names list is not yet defined"
       )
@@ -142,7 +142,7 @@ describe('Worker node test suite', () => {
     threadWorkerNode.info.taskFunctionNames = [DEFAULT_TASK_NAME, 'fn1']
     expect(() =>
       threadWorkerNode.getTaskFunctionWorkerUsage('invalidTaskFunction')
-    ).toThrowError(
+    ).toThrow(
       new TypeError(
         "Cannot get task function worker usage for task function name 'invalidTaskFunction' when task function names list has less than 3 elements"
       )
index 575e065132b889ad4b96ba7f1440ab5db23b2759..4abbbeb1e17a0ff0528944e0f6e8707e4ad607d5 100644 (file)
@@ -25,39 +25,35 @@ describe('Abstract worker test suite', () => {
   })
 
   it('Verify that worker options are checked at worker creation', () => {
-    expect(() => new ClusterWorker(() => {}, '')).toThrowError(
+    expect(() => new ClusterWorker(() => {}, '')).toThrow(
       new TypeError('opts worker options parameter is not a plain object')
     )
-    expect(
-      () => new ClusterWorker(() => {}, { killBehavior: '' })
-    ).toThrowError(new TypeError("killBehavior option '' is not valid"))
-    expect(() => new ClusterWorker(() => {}, { killBehavior: 0 })).toThrowError(
+    expect(() => new ClusterWorker(() => {}, { killBehavior: '' })).toThrow(
+      new TypeError("killBehavior option '' is not valid")
+    )
+    expect(() => new ClusterWorker(() => {}, { killBehavior: 0 })).toThrow(
       new TypeError("killBehavior option '0' is not valid")
     )
-    expect(
-      () => new ThreadWorker(() => {}, { maxInactiveTime: '' })
-    ).toThrowError(new TypeError('maxInactiveTime option is not an integer'))
-    expect(
-      () => new ThreadWorker(() => {}, { maxInactiveTime: 0.5 })
-    ).toThrowError(new TypeError('maxInactiveTime option is not an integer'))
-    expect(
-      () => new ThreadWorker(() => {}, { maxInactiveTime: 0 })
-    ).toThrowError(
+    expect(() => new ThreadWorker(() => {}, { maxInactiveTime: '' })).toThrow(
+      new TypeError('maxInactiveTime option is not an integer')
+    )
+    expect(() => new ThreadWorker(() => {}, { maxInactiveTime: 0.5 })).toThrow(
+      new TypeError('maxInactiveTime option is not an integer')
+    )
+    expect(() => new ThreadWorker(() => {}, { maxInactiveTime: 0 })).toThrow(
       new TypeError(
         'maxInactiveTime option is not a positive integer greater or equal than 5'
       )
     )
-    expect(
-      () => new ThreadWorker(() => {}, { maxInactiveTime: 4 })
-    ).toThrowError(
+    expect(() => new ThreadWorker(() => {}, { maxInactiveTime: 4 })).toThrow(
       new TypeError(
         'maxInactiveTime option is not a positive integer greater or equal than 5'
       )
     )
-    expect(() => new ThreadWorker(() => {}, { killHandler: '' })).toThrowError(
+    expect(() => new ThreadWorker(() => {}, { killHandler: '' })).toThrow(
       new TypeError('killHandler option is not a function')
     )
-    expect(() => new ThreadWorker(() => {}, { killHandler: 0 })).toThrowError(
+    expect(() => new ThreadWorker(() => {}, { killHandler: 0 })).toThrow(
       new TypeError('killHandler option is not a function')
     )
   })
@@ -79,48 +75,48 @@ describe('Abstract worker test suite', () => {
   })
 
   it('Verify that taskFunctions parameter is mandatory', () => {
-    expect(() => new ClusterWorker()).toThrowError(
+    expect(() => new ClusterWorker()).toThrow(
       new Error('taskFunctions parameter is mandatory')
     )
   })
 
   it('Verify that taskFunctions parameter is a function or a plain object', () => {
-    expect(() => new ClusterWorker(0)).toThrowError(
+    expect(() => new ClusterWorker(0)).toThrow(
       new TypeError(
         'taskFunctions parameter is not a function or a plain object'
       )
     )
-    expect(() => new ClusterWorker('')).toThrowError(
+    expect(() => new ClusterWorker('')).toThrow(
       new TypeError(
         'taskFunctions parameter is not a function or a plain object'
       )
     )
-    expect(() => new ClusterWorker(true)).toThrowError(
+    expect(() => new ClusterWorker(true)).toThrow(
       new TypeError(
         'taskFunctions parameter is not a function or a plain object'
       )
     )
-    expect(() => new ClusterWorker([])).toThrowError(
+    expect(() => new ClusterWorker([])).toThrow(
       new TypeError(
         'taskFunctions parameter is not a function or a plain object'
       )
     )
-    expect(() => new ClusterWorker(new Map())).toThrowError(
+    expect(() => new ClusterWorker(new Map())).toThrow(
       new TypeError(
         'taskFunctions parameter is not a function or a plain object'
       )
     )
-    expect(() => new ClusterWorker(new Set())).toThrowError(
+    expect(() => new ClusterWorker(new Set())).toThrow(
       new TypeError(
         'taskFunctions parameter is not a function or a plain object'
       )
     )
-    expect(() => new ClusterWorker(new WeakMap())).toThrowError(
+    expect(() => new ClusterWorker(new WeakMap())).toThrow(
       new TypeError(
         'taskFunctions parameter is not a function or a plain object'
       )
     )
-    expect(() => new ClusterWorker(new WeakSet())).toThrowError(
+    expect(() => new ClusterWorker(new WeakSet())).toThrow(
       new TypeError(
         'taskFunctions parameter is not a function or a plain object'
       )
@@ -128,7 +124,7 @@ describe('Abstract worker test suite', () => {
   })
 
   it('Verify that taskFunctions parameter is not an empty object', () => {
-    expect(() => new ClusterWorker({})).toThrowError(
+    expect(() => new ClusterWorker({})).toThrow(
       new Error('taskFunctions parameter object is empty')
     )
   })
@@ -148,10 +144,10 @@ describe('Abstract worker test suite', () => {
       return 1
     }
     const fn2 = ''
-    expect(() => new ThreadWorker({ '': fn1 })).toThrowError(
+    expect(() => new ThreadWorker({ '': fn1 })).toThrow(
       new TypeError('A taskFunctions parameter object key is an empty string')
     )
-    expect(() => new ThreadWorker({ fn1, fn2 })).toThrowError(
+    expect(() => new ThreadWorker({ fn1, fn2 })).toThrow(
       new TypeError('A taskFunctions parameter object value is not a function')
     )
   })
@@ -186,7 +182,7 @@ describe('Abstract worker test suite', () => {
   it('Verify that getMainWorker() throw error if main worker is not set', () => {
     expect(() =>
       new StubWorkerWithMainWorker(() => {}).getMainWorker()
-    ).toThrowError('Main worker not set')
+    ).toThrow('Main worker not set')
   })
 
   it('Verify that hasTaskFunction() is working', () => {