add test for passing headers on job creation

This commit is contained in:
2016-07-21 14:34:31 -07:00
parent 2c5519c253
commit 597052dc4e
3 changed files with 21 additions and 1 deletions

View File

@@ -113,5 +113,4 @@ export default class Job extends events.EventEmitter {
priority: this.priority, priority: this.priority,
}); });
} }
} }

View File

@@ -95,6 +95,16 @@ describe('Esqueue class', function () {
const job = queue.addJob(jobType, payload); const job = queue.addJob(jobType, payload);
expect(job.getProp('options')).to.have.property('indexSettings', indexSettings); 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 () { describe('Registering workers', function () {

View File

@@ -256,6 +256,9 @@ describe('Job Class', function () {
options = { options = {
timeout: 4567, timeout: 4567,
max_attempts: 9, max_attempts: 9,
headers: {
authorization: 'Basic cXdlcnR5'
}
}; };
sinon.spy(client, 'index'); 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 () { it(`should use upper priority of ${maxPriority}`, function () {
const job = new Job(mockQueue, index, type, payload, { priority: maxPriority * 2 }); const job = new Job(mockQueue, index, type, payload, { priority: maxPriority * 2 });
return job.ready.then(() => { return job.ready.then(() => {