From 597052dc4eb8f41162e5b2ec3cc73a9cebb81e96 Mon Sep 17 00:00:00 2001 From: Joe Fleming Date: Thu, 21 Jul 2016 14:34:31 -0700 Subject: [PATCH] add test for passing headers on job creation --- src/job.js | 1 - test/src/index.js | 10 ++++++++++ test/src/job.js | 11 +++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/job.js b/src/job.js index 2894752..0780786 100644 --- a/src/job.js +++ b/src/job.js @@ -113,5 +113,4 @@ export default class Job extends events.EventEmitter { priority: this.priority, }); } - } diff --git a/test/src/index.js b/test/src/index.js index 299473a..3d38677 100644 --- a/test/src/index.js +++ b/test/src/index.js @@ -95,6 +95,16 @@ describe('Esqueue class', function () { const job = queue.addJob(jobType, payload); expect(job.getProp('options')).to.have.property('indexSettings', indexSettings); }); + + it('should pass headers from options', function () { + const options = { + headers: { + authorization: 'Basic cXdlcnR5' + } + }; + const job = queue.addJob(jobType, payload, options); + expect(job.getProp('options')).to.have.property('headers', options.headers); + }); }); describe('Registering workers', function () { diff --git a/test/src/job.js b/test/src/job.js index 4683960..a70c0c4 100644 --- a/test/src/job.js +++ b/test/src/job.js @@ -256,6 +256,9 @@ describe('Job Class', function () { options = { timeout: 4567, max_attempts: 9, + headers: { + authorization: 'Basic cXdlcnR5' + } }; sinon.spy(client, 'index'); }); @@ -285,6 +288,14 @@ describe('Job Class', function () { }); }); + it('should add headers to the request params', function () { + const job = new Job(mockQueue, index, type, payload, options); + return job.ready.then(() => { + const indexArgs = validateDoc(client.index); + expect(indexArgs).to.have.property('headers', options.headers); + }); + }); + it(`should use upper priority of ${maxPriority}`, function () { const job = new Job(mockQueue, index, type, payload, { priority: maxPriority * 2 }); return job.ready.then(() => {