X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=tests%2Fworker%2Fcluster-worker.test.js;h=085e07a34e517e963b1e9a39cea56bb49f4d7cd9;hb=aa4bf4b27479408af59e1cd36b98fe0c22bc7f03;hp=ff749c8f721f964762c144ece84a7933711367fa;hpb=78cea37e264d5ca527bc42eb056f3b9579a2b2c4;p=poolifier.git diff --git a/tests/worker/cluster-worker.test.js b/tests/worker/cluster-worker.test.js index ff749c8f..085e07a3 100644 --- a/tests/worker/cluster-worker.test.js +++ b/tests/worker/cluster-worker.test.js @@ -2,14 +2,24 @@ const { expect } = require('expect') const { ClusterWorker } = require('../../lib') describe('Cluster worker test suite', () => { + let numberOfMessagesSent = 0 + const send = function () { + ++numberOfMessagesSent + } + class SpyWorker extends ClusterWorker { + getMainWorker () { + return { send } + } + } + it('Verify worker has default maxInactiveTime', () => { const worker = new ClusterWorker(() => {}) expect(worker.opts.maxInactiveTime).toStrictEqual(60000) }) - it('Verify that handleError function works properly', () => { - const errorMessage = 'Error as a string' - const worker = new ClusterWorker(() => {}) - expect(worker.handleError(errorMessage)).toStrictEqual(errorMessage) + it('Verify worker invokes the getMainWorker() and send() methods', () => { + const worker = new SpyWorker(() => {}) + worker.sendToMainWorker({ ok: 1 }) + expect(numberOfMessagesSent).toBe(1) }) })