it('Verify that taskFunctions parameter with unique function is taken', () => {
const worker = new ThreadWorker(() => {})
- expect(worker.taskFunctions.get(DEFAULT_TASK_NAME)).toBeInstanceOf(Object)
- expect(worker.taskFunctions.get('fn1')).toBeInstanceOf(Object)
+ expect(worker.taskFunctions.get(DEFAULT_TASK_NAME)).toStrictEqual({
+ taskFunction: expect.any(Function)
+ })
+ expect(worker.taskFunctions.get('fn1')).toStrictEqual({
+ taskFunction: expect.any(Function)
+ })
expect(worker.taskFunctions.size).toBe(2)
expect(worker.taskFunctions.get(DEFAULT_TASK_NAME)).toStrictEqual(
worker.taskFunctions.get('fn1')
)
expect(
() => new ThreadWorker({ fn1: { taskFunction: fn1, priority: '' } })
- ).toThrow(new TypeError("Invalid priority ''"))
+ ).toThrow(new TypeError("Invalid property 'priority': ''"))
expect(
() => new ThreadWorker({ fn1: { taskFunction: fn1, priority: -21 } })
- ).toThrow(new TypeError('Property priority must be between -20 and 19'))
+ ).toThrow(new TypeError("Property 'priority' must be between -20 and 19"))
expect(
() => new ThreadWorker({ fn1: { taskFunction: fn1, priority: 20 } })
- ).toThrow(new RangeError('Property priority must be between -20 and 19'))
+ ).toThrow(new RangeError("Property 'priority' must be between -20 and 19"))
expect(
() =>
new ThreadWorker({
return 2
}
const worker = new ClusterWorker({ fn1, fn2 })
- expect(worker.taskFunctions.get(DEFAULT_TASK_NAME)).toBeInstanceOf(Object)
- expect(worker.taskFunctions.get('fn1')).toBeInstanceOf(Object)
- expect(worker.taskFunctions.get('fn2')).toBeInstanceOf(Object)
+ expect(worker.taskFunctions.get(DEFAULT_TASK_NAME)).toStrictEqual({
+ taskFunction: expect.any(Function)
+ })
+ expect(worker.taskFunctions.get('fn1')).toStrictEqual({
+ taskFunction: expect.any(Function)
+ })
+ expect(worker.taskFunctions.get('fn2')).toStrictEqual({
+ taskFunction: expect.any(Function)
+ })
expect(worker.taskFunctions.size).toBe(3)
expect(worker.taskFunctions.get(DEFAULT_TASK_NAME)).toStrictEqual(
worker.taskFunctions.get('fn1')
"taskFunction object 'taskFunction' property 'undefined' is not a function"
)
})
- expect(worker.taskFunctions.get(DEFAULT_TASK_NAME)).toBeInstanceOf(Object)
- expect(worker.taskFunctions.get('fn1')).toBeInstanceOf(Object)
+ expect(worker.taskFunctions.get(DEFAULT_TASK_NAME)).toStrictEqual({
+ taskFunction: expect.any(Function)
+ })
+ expect(worker.taskFunctions.get('fn1')).toStrictEqual({
+ taskFunction: expect.any(Function)
+ })
expect(worker.taskFunctions.size).toBe(2)
expect(worker.taskFunctions.get(DEFAULT_TASK_NAME)).toStrictEqual(
worker.taskFunctions.get('fn1')
)
})
worker.addTaskFunction('fn2', fn2)
- expect(worker.taskFunctions.get(DEFAULT_TASK_NAME)).toBeInstanceOf(Object)
- expect(worker.taskFunctions.get('fn1')).toBeInstanceOf(Object)
- expect(worker.taskFunctions.get('fn2')).toBeInstanceOf(Object)
+ expect(worker.taskFunctions.get(DEFAULT_TASK_NAME)).toStrictEqual({
+ taskFunction: expect.any(Function)
+ })
+ expect(worker.taskFunctions.get('fn1')).toStrictEqual({
+ taskFunction: expect.any(Function)
+ })
+ expect(worker.taskFunctions.get('fn2')).toStrictEqual({
+ taskFunction: expect.any(Function)
+ })
expect(worker.taskFunctions.size).toBe(3)
expect(worker.taskFunctions.get(DEFAULT_TASK_NAME)).toStrictEqual(
worker.taskFunctions.get('fn1')
)
worker.addTaskFunction('fn1', fn1Replacement)
- expect(worker.taskFunctions.get(DEFAULT_TASK_NAME)).toBeInstanceOf(Object)
- expect(worker.taskFunctions.get('fn1')).toBeInstanceOf(Object)
- expect(worker.taskFunctions.get('fn2')).toBeInstanceOf(Object)
+ expect(worker.taskFunctions.get(DEFAULT_TASK_NAME)).toStrictEqual({
+ taskFunction: expect.any(Function)
+ })
+ expect(worker.taskFunctions.get('fn1')).toStrictEqual({
+ taskFunction: expect.any(Function)
+ })
+ expect(worker.taskFunctions.get('fn2')).toStrictEqual({
+ taskFunction: expect.any(Function)
+ })
expect(worker.taskFunctions.size).toBe(3)
expect(worker.taskFunctions.get(DEFAULT_TASK_NAME)).toStrictEqual(
worker.taskFunctions.get('fn1')
)
})
- it('Verify that listTaskFunctionNames() is working', () => {
+ it('Verify that listTaskFunctionsProperties() is working', () => {
const fn1 = () => {
return 1
}
status: false,
error: new TypeError('name parameter is an empty string')
})
- expect(worker.taskFunctions.get(DEFAULT_TASK_NAME)).toBeInstanceOf(Object)
- expect(worker.taskFunctions.get('fn1')).toBeInstanceOf(Object)
- expect(worker.taskFunctions.get('fn2')).toBeInstanceOf(Object)
+ expect(worker.taskFunctions.get(DEFAULT_TASK_NAME)).toStrictEqual({
+ taskFunction: expect.any(Function)
+ })
+ expect(worker.taskFunctions.get('fn1')).toStrictEqual({
+ taskFunction: expect.any(Function)
+ })
+ expect(worker.taskFunctions.get('fn2')).toStrictEqual({
+ taskFunction: expect.any(Function)
+ })
expect(worker.taskFunctions.size).toBe(3)
expect(worker.taskFunctions.get(DEFAULT_TASK_NAME)).toStrictEqual(
worker.taskFunctions.get('fn1')