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 | 17 | |
292ad316 | 18 | it('Verify that handleError function is working properly', () => { |
7fc5cce6 APA |
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() | |
292ad316 | 27 | ).toThrowError(new Error('Main worker was not set')) |
7fc5cce6 | 28 | }) |
c510fea7 | 29 | }) |