refactor: sensible defaults for worker choice strategy policy
[poolifier.git] / tests / worker / cluster-worker.test.js
CommitLineData
a61a0724 1const { expect } = require('expect')
fd027a65
S
2const { ClusterWorker } = require('../../lib')
3
4describe('Cluster worker test suite', () => {
f4fb3543 5 let numberOfMessagesSent = 0
440dd7d7 6 const send = () => {
f4fb3543
JB
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})