add test for passing headers on job creation
This commit is contained in:
@@ -113,5 +113,4 @@ export default class Job extends events.EventEmitter {
|
|||||||
priority: this.priority,
|
priority: this.priority,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 () {
|
||||||
|
|||||||
@@ -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(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user