From 288daecb6b669e3c6ee80cdba0125e96cac46202 Mon Sep 17 00:00:00 2001 From: Joe Fleming Date: Mon, 11 Jul 2016 11:32:47 -0700 Subject: [PATCH] Job - add emit on Queue instance test --- test/src/job.js | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/test/src/job.js b/test/src/job.js index e051495..317a794 100644 --- a/test/src/job.js +++ b/test/src/job.js @@ -161,6 +161,33 @@ describe('Job Class', function () { }); }); + describe('event emitting', function () { + it('should trigger events on the queue instance', function (done) { + const eventName = 'test event'; + const payload1 = { + test: true, + deep: { object: 'ok' } + }; + const payload2 = 'two'; + const payload3 = new Error('test error'); + + const job = new Job(mockQueue, index, type, payload, options); + + mockQueue.on(eventName, (...args) => { + try { + expect(args[0]).to.equal(payload1); + expect(args[1]).to.equal(payload2); + expect(args[2]).to.equal(payload3); + done(); + } catch (e) { + done(e); + } + }); + + job.emit(eventName, payload1, payload2, payload3); + }); + }); + describe('default values', function () { beforeEach(function () { type = 'type1'; @@ -209,7 +236,6 @@ describe('Job Class', function () { expect(indexArgs.body).to.have.property('priority', defaultPriority); }); }); - }); describe('option passing', function () {