Merge branch 'master' of github.com:jerome-benoit/poolifier
[poolifier.git] / tests / worker / cluster-worker.test.js
1 const { expect } = require('expect')
2 const { ClusterWorker } = require('../../lib')
3
4 describe('Cluster worker test suite', () => {
5 let numberOfMessagesSent = 0
6 const send = () => {
7 ++numberOfMessagesSent
8 }
9 class SpyWorker extends ClusterWorker {
10 getMainWorker () {
11 return { send }
12 }
13 }
14
15 it('Verify worker invokes the getMainWorker() and send() methods', () => {
16 const worker = new SpyWorker(() => {})
17 worker.sendToMainWorker({ ok: 1 })
18 expect(numberOfMessagesSent).toBe(1)
19 })
20 })