1 const expect
= require('expect')
2 const { ClusterWorker
, ThreadWorker
} = require('../../lib')
4 class StubPoolWithIsMainWorker
extends ThreadWorker
{
5 constructor (fn
, opts
) {
7 this.mainWorker
= false
11 describe('Abstract worker test suite', () => {
12 it('Verify that fn function is mandatory', () => {
13 expect(() => new ClusterWorker()).toThrowError(
14 new Error('fn parameter is mandatory')
18 it('Verify that handle Error function is working properly', () => {
19 const error
= new Error('My error')
20 const worker
= new ThreadWorker(() => {})
21 expect(worker
.handleError(error
)).toBe(error
)
24 it('Verify that get main worker throw error if main worker is not set', () => {
26 new StubPoolWithIsMainWorker(() => {}).getMainWorker()