- expect(() => {
- const pool = new StubPoolWithIsMainMethod(1).toThrowError()
- })
- expect(() => {
- const pool = new StubPoolWithIsMainMethod(1, '').toThrowError()
- })
+ expect(() => new StubPoolWithIsMainMethod(1)).toThrowError(
+ new Error('Cannot start a pool from a worker!')
+ )
+ expect(() => new StubPoolWithIsMainMethod(1, '')).toThrowError(
+ new Error('Cannot start a pool from a worker!')
+ )
+ })
+
+ it('Verify that numberOfWorkers is checked', () => {
+ expect(() => new FixedThreadPool()).toThrowError(
+ new Error(
+ 'Cannot instantiate a pool without specifying the number of workers'
+ )
+ )
+ })
+
+ it('Verify that a negative number of workers is checked', () => {
+ expect(
+ () =>
+ new FixedClusterPool(-1, './tests/worker-files/cluster/testWorker.js')
+ ).toThrowError(
+ new Error('Cannot instantiate a pool with a negative number of workers')
+ )
+ })
+
+ it('Verify that a non integer number of workers is checked', () => {
+ expect(
+ () =>
+ new FixedThreadPool(0.25, './tests/worker-files/thread/testWorker.js')
+ ).toThrowError(
+ new Error(
+ 'Cannot instantiate a pool with a non integer number of workers'
+ )
+ )