Skip to content

Commit

Permalink
test: alternative error format
Browse files Browse the repository at this point in the history
  • Loading branch information
Justintime50 committed Feb 21, 2025
1 parent 8382393 commit 20b8d47
Show file tree
Hide file tree
Showing 2 changed files with 175 additions and 0 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions test/services/error.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import TimeoutError from '../../src/errors/api/timeout_error';
import UnauthorizedError from '../../src/errors/api/unauthorized_error';
import UnknownApiError from '../../src/errors/api/unknown_api_error';
import ErrorHandler from '../../src/errors/error_handler';
import Fixture from '../helpers/fixture';
import * as setupPolly from '../helpers/setup_polly';

describe('Error Service', function () {
Expand All @@ -39,6 +40,17 @@ describe('Error Service', function () {
});
});

it('pulls out error properties of an API error when using the alternative format', async function () {
const claimData = Fixture.basicClaim();
claimData.tracking_code = '123'; // Intentionally pass a bad tracking code
await client.Claim.create(claimData).catch((error) => {
expect(error.statusCode).to.equal(404);
expect(error.code).to.equal('NOT_FOUND');
expect(error.message).to.equal('The requested resource could not be found.');
assert.deepEqual(error.errors[0], 'No eligible insurance found with provided tracking code.');
});
});

it('test error array parsing', () => {
const fakeErrorResponse = {
statusCode: 404,
Expand Down

0 comments on commit 20b8d47

Please sign in to comment.