Commit | Line | Data |
---|---|---|
a61a0724 | 1 | const { expect } = require('expect') |
fd027a65 S |
2 | const { ClusterWorker } = require('../../lib') |
3 | ||
4 | describe('Cluster worker test suite', () => { | |
f4fb3543 JB |
5 | let numberOfMessagesSent = 0 |
6 | const send = function () { | |
7 | ++numberOfMessagesSent | |
8 | } | |
9 | class SpyWorker extends ClusterWorker { | |
10 | getMainWorker () { | |
11 | return { send } | |
12 | } | |
13 | } | |
14 | ||
8d3782fa | 15 | it('Verify worker has default maxInactiveTime', () => { |
fd027a65 | 16 | const worker = new ClusterWorker(() => {}) |
e1ffb94f | 17 | expect(worker.opts.maxInactiveTime).toStrictEqual(60000) |
fd027a65 | 18 | }) |
7fc5cce6 | 19 | |
2431bdb4 | 20 | it('Verify worker invokes the getMainWorker() and send() methods', () => { |
f4fb3543 JB |
21 | const worker = new SpyWorker(() => {}) |
22 | worker.sendToMainWorker({ ok: 1 }) | |
23 | expect(numberOfMessagesSent).toBe(1) | |
24 | }) | |
fd027a65 | 25 | }) |