replace typed errors with custom errors
This commit is contained in:
51
test/src/helpers/errors.js
Normal file
51
test/src/helpers/errors.js
Normal 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');
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user