Commit | Line | Data |
---|---|---|
c510fea7 | 1 | const expect = require('expect') |
7fc5cce6 APA |
2 | const { ClusterWorker, ThreadWorker } = require('../../lib') |
3 | ||
4 | class StubPoolWithIsMainWorker extends ThreadWorker { | |
5 | constructor (fn, opts) { | |
6 | super(fn, opts) | |
7 | this.mainWorker = false | |
8 | } | |
9 | } | |
c510fea7 APA |
10 | |
11 | describe('Abstract worker test suite', () => { | |
12 | it('Verify that fn function is mandatory', () => { | |
8d3782fa JB |
13 | expect(() => new ClusterWorker()).toThrowError( |
14 | new Error('fn parameter is mandatory') | |
15 | ) | |
c510fea7 | 16 | }) |
7fc5cce6 APA |
17 | |
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) | |
22 | }) | |
23 | ||
24 | it('Verify that get main worker throw error if main worker is not set', () => { | |
25 | expect(() => | |
26 | new StubPoolWithIsMainWorker(() => {}).getMainWorker() | |
27 | ).toThrowError() | |
28 | }) | |
c510fea7 | 29 | }) |