Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: alternative error format #495

Merged
merged 2 commits into from
Feb 28, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
test: alternative error format
Justintime50 committed Feb 21, 2025
commit 20b8d47fe19514ba663d98ac1f98b64ef4765c4d

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
@@ -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 () {
@@ -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,