replace typed errors with custom errors

This commit is contained in:
2017-02-28 15:44:28 -07:00
parent 1e8340f214
commit 9cff4e4b04
2 changed files with 68 additions and 16 deletions

View File

@@ -0,0 +1,51 @@
import expect from 'expect.js';
import { WorkerTimeoutError, UnspecifiedWorkerError } from '../../../lib/helpers/errors';
describe('custom errors', function () {
describe('WorkerTimeoutError', function () {
it('should be function', () => {
expect(WorkerTimeoutError).to.be.a('function');
});
it('should have a name', function () {
const err = new WorkerTimeoutError('timeout error');
expect(err).to.have.property('name', 'WorkerTimeoutError');
});
it('should take a jobId property', function () {
const err = new WorkerTimeoutError('timeout error', { jobId: 'il7hl34rqlo8ro' });
expect(err).to.have.property('jobId', 'il7hl34rqlo8ro');
});
it('should take a timeout property', function () {
const err = new WorkerTimeoutError('timeout error', { timeout: 15000 });
expect(err).to.have.property('timeout', 15000);
});
it('should be stringifyable', function () {
const err = new WorkerTimeoutError('timeout error');
expect(`${err}`).to.equal('WorkerTimeoutError: timeout error');
});
});
describe('UnspecifiedWorkerError', function () {
it('should be function', () => {
expect(UnspecifiedWorkerError).to.be.a('function');
});
it('should have a name', function () {
const err = new UnspecifiedWorkerError('unspecified error');
expect(err).to.have.property('name', 'UnspecifiedWorkerError');
});
it('should take a jobId property', function () {
const err = new UnspecifiedWorkerError('unspecified error', { jobId: 'il7hl34rqlo8ro' });
expect(err).to.have.property('jobId', 'il7hl34rqlo8ro');
});
it('should be stringifyable', function () {
const err = new UnspecifiedWorkerError('unspecified error');
expect(`${err}`).to.equal('UnspecifiedWorkerError: unspecified error');
});
});
});