add test for passing headers on job creation
This commit is contained in:
@@ -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 () {
|
||||
|
||||
@@ -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(() => {
|
||||
|
||||
Reference in New Issue
Block a user