Merge dependabot/npm_and_yarn/examples/typescript/http-server-pool/express-hybrid...
[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
2431bdb4 15 it('Verify worker invokes the getMainWorker() and send() methods', () => {
f4fb3543
JB
16 const worker = new SpyWorker(() => {})
17 worker.sendToMainWorker({ ok: 1 })
18 expect(numberOfMessagesSent).toBe(1)
19 })
fd027a65 20})