+ ),
+ })
+ expect(worker.addTaskFunction('fn2', { taskFunction: 0 })).toStrictEqual({
+ status: false,
+ error: new TypeError(
+ "taskFunction object 'taskFunction' property '0' is not a function"
+ ),
+ })
+ expect(worker.addTaskFunction('fn3', { taskFunction: '' })).toStrictEqual({
+ status: false,
+ error: new TypeError(
+ "taskFunction object 'taskFunction' property '' is not a function"
+ ),
+ })
+ expect(
+ worker.addTaskFunction('fn2', { taskFunction: () => {}, priority: -21 })
+ ).toStrictEqual({
+ status: false,
+ error: new RangeError("Property 'priority' must be between -20 and 19"),
+ })
+ expect(
+ worker.addTaskFunction('fn3', { taskFunction: () => {}, priority: 20 })
+ ).toStrictEqual({
+ status: false,
+ error: new RangeError("Property 'priority' must be between -20 and 19"),
+ })
+ expect(
+ worker.addTaskFunction('fn2', {
+ taskFunction: () => {},
+ strategy: 'invalidStrategy',
+ })
+ ).toStrictEqual({
+ status: false,
+ error: new Error("Invalid worker choice strategy 'invalidStrategy'"),
+ })
+ expect(worker.taskFunctions.get(DEFAULT_TASK_NAME)).toStrictEqual({
+ taskFunction: expect.any(Function),
+ })
+ expect(worker.taskFunctions.get('fn1')).toStrictEqual({
+ taskFunction: expect.any(Function),