-
Notifications
You must be signed in to change notification settings - Fork 482
/
MakerErrorTest.js
31 lines (29 loc) · 1.17 KB
/
MakerErrorTest.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/** @file Tests for our MakerError classes */
import {expect} from '../../../../util/configuredChai';
import MakerError, {
ConnectionFailedError,
wrapKnownMakerErrors
} from '@cdo/apps/lib/kits/maker/MakerError';
describe('MakerError', () => {
describe('wrapKnownMakerErrors(originalError)', () => {
it(`returns the original error if it's not a known common maker error`, () => {
const testError = new Error('Some test error.');
const returnedError = wrapKnownMakerErrors(testError);
expect(returnedError)
.to.equal(testError)
.and.not.to.be.an.instanceOf(MakerError);
});
it(`returns a ConnectionFailedError on a johnny-five timeout error`, () => {
const j5TimeoutMessage =
'A timeout occurred while connecting to the Board.' +
'\n\nSomething something error stuff.';
const testError = new Error(j5TimeoutMessage);
const returnedError = wrapKnownMakerErrors(testError);
expect(returnedError)
.to.be.an.instanceOf(MakerError)
.and.to.be.an.instanceOf(ConnectionFailedError)
.and.to.have.property('reason', j5TimeoutMessage)
.and.not.to.equal(testError);
});
});
});