chore: rename module to elastiq

This commit is contained in:
2017-08-08 19:34:48 -07:00
parent 170ba3b8a0
commit 83a0352202
8 changed files with 40 additions and 40 deletions

View File

@@ -8,12 +8,12 @@ import elasticsearchMock from '../fixtures/elasticsearch';
import jobMock from '../fixtures/job';
import workerMock from '../fixtures/worker';
const Esqueue = proxyquire.noPreserveCache()('../../lib/index', {
const Queue = proxyquire.noPreserveCache()('../../lib/index', {
'./job.js': jobMock,
'./worker.js': workerMock,
});
describe('Esqueue class', function () {
describe('Elastiq class', function () {
let client;
beforeEach(function () {
@@ -21,18 +21,18 @@ describe('Esqueue class', function () {
});
it('should be an event emitter', function () {
const queue = new Esqueue('esqueue', { client });
const queue = new Queue('elastiq', { client });
expect(queue).to.be.an(events.EventEmitter);
});
describe('Option validation', function () {
it('should throw without an index', function () {
const init = () => new Esqueue();
const init = () => new Queue();
expect(init).to.throwException(/must.+specify.+index/i);
});
it('should throw with an invalid host', function () {
const init = () => new Esqueue('esqueue', {
const init = () => new Queue('elastiq', {
client: { host: 'nope://nope' }
});
@@ -40,7 +40,7 @@ describe('Esqueue class', function () {
});
it('should throw with invalid hosts', function () {
const init = () => new Esqueue('esqueue', {
const init = () => new Queue('elastiq', {
client: { hosts: [{ host: 'localhost', protocol: 'nope' }] }
});
@@ -51,7 +51,7 @@ describe('Esqueue class', function () {
describe('Queue construction', function () {
it('should ping the ES server', function () {
const pingSpy = sinon.spy(client, 'ping');
new Esqueue('esqueue', { client });
new Queue('elastiq', { client });
sinon.assert.calledOnce(pingSpy);
});
});
@@ -63,14 +63,14 @@ describe('Esqueue class', function () {
let queue;
beforeEach(function () {
indexName = 'esqueue-index';
indexName = 'elastiq-index';
jobType = 'test-test';
payload = { payload: true };
queue = new Esqueue(indexName, { client });
queue = new Queue(indexName, { client });
});
it('should throw with invalid dateSeparator setting', function () {
queue = new Esqueue(indexName, { client, dateSeparator: 'a' });
queue = new Queue(indexName, { client, dateSeparator: 'a' });
const fn = () => queue.addJob(jobType, payload);
expect(fn).to.throwException();
});
@@ -97,7 +97,7 @@ describe('Esqueue class', function () {
}
};
queue = new Esqueue(indexName, { client, indexSettings });
queue = new Queue(indexName, { client, indexSettings });
const job = queue.addJob(jobType, payload);
expect(job.getProp('options')).to.have.property('indexSettings', indexSettings);
});
@@ -117,7 +117,7 @@ describe('Esqueue class', function () {
let queue;
beforeEach(function () {
queue = new Esqueue('esqueue', { client });
queue = new Queue('elastiq', { client });
});
it('should keep track of workers', function () {
@@ -146,7 +146,7 @@ describe('Esqueue class', function () {
doctype: 'tests'
};
queue = new Esqueue('esqueue', { client });
queue = new Queue('elastiq', { client });
const worker = queue.registerWorker('type', noop, workerOptions);
expect(worker.getProp('options')).to.equal(workerOptions);
});
@@ -154,7 +154,7 @@ describe('Esqueue class', function () {
describe('Destroy', function () {
it('should destroy workers', function () {
const queue = new Esqueue('esqueue', { client });
const queue = new Queue('elastiq', { client });
const stubs = times(3, () => { return { destroy: sinon.stub() }; });
stubs.forEach((stub) => queue._workers.push(stub));
expect(queue.getWorkers()).to.have.length(3);