ensure objects are event emitters

This commit is contained in:
2016-04-15 17:29:40 -07:00
parent 9f495c7791
commit 5ce288fd72
2 changed files with 14 additions and 2 deletions

View File

@@ -1,7 +1,13 @@
import Elastique from '../../lib/index'; import events from 'events';
import expect from 'expect.js'; import expect from 'expect.js';
import Elastique from '../../lib/index';
describe('Elastique class', function () { describe('Elastique class', function () {
it('should be an event emitter', function () {
const queue = new Elastique('elastique');
expect(queue).to.be.an(events.EventEmitter);
});
describe('Option validation', function () { describe('Option validation', function () {
it('should throw without an index', function () { it('should throw without an index', function () {
const init = () => new Elastique(); const init = () => new Elastique();

View File

@@ -1,3 +1,4 @@
import events from 'events';
import expect from 'expect.js'; import expect from 'expect.js';
import sinon from 'sinon'; import sinon from 'sinon';
import Job from '../../lib/job'; import Job from '../../lib/job';
@@ -12,7 +13,12 @@ describe('Jobs', function () {
}; };
}); });
describe('invlaid construction', function () { it('should be an event emitter', function () {
const job = new Job(mockQueue, 'test', {});
expect(job).to.be.an(events.EventEmitter);
});
describe('invalid construction', function () {
it('should throw with a missing type', function () { it('should throw with a missing type', function () {
const init = () => new Job(mockQueue); const init = () => new Job(mockQueue);
expect(init).to.throwException(/type.+string/i); expect(init).to.throwException(/type.+string/i);