Skip to content

Commit 20b8d47

Browse files
committed
test: alternative error format
1 parent 8382393 commit 20b8d47

File tree

2 files changed

+175
-0
lines changed
  • test
    • cassettes/Error-Service_386538342/pulls-out-error-properties-of-an-API-error-when-using-the-alternative-format_650479431
    • services

2 files changed

+175
-0
lines changed

test/cassettes/Error-Service_386538342/pulls-out-error-properties-of-an-API-error-when-using-the-alternative-format_650479431/recording.har

Lines changed: 163 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/services/error.test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import TimeoutError from '../../src/errors/api/timeout_error';
1515
import UnauthorizedError from '../../src/errors/api/unauthorized_error';
1616
import UnknownApiError from '../../src/errors/api/unknown_api_error';
1717
import ErrorHandler from '../../src/errors/error_handler';
18+
import Fixture from '../helpers/fixture';
1819
import * as setupPolly from '../helpers/setup_polly';
1920

2021
describe('Error Service', function () {
@@ -39,6 +40,17 @@ describe('Error Service', function () {
3940
});
4041
});
4142

43+
it('pulls out error properties of an API error when using the alternative format', async function () {
44+
const claimData = Fixture.basicClaim();
45+
claimData.tracking_code = '123'; // Intentionally pass a bad tracking code
46+
await client.Claim.create(claimData).catch((error) => {
47+
expect(error.statusCode).to.equal(404);
48+
expect(error.code).to.equal('NOT_FOUND');
49+
expect(error.message).to.equal('The requested resource could not be found.');
50+
assert.deepEqual(error.errors[0], 'No eligible insurance found with provided tracking code.');
51+
});
52+
});
53+
4254
it('test error array parsing', () => {
4355
const fakeErrorResponse = {
4456
statusCode: 404,

0 commit comments

Comments
 (0)