Skip to content

Commit

Permalink
tcrasset feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-fidd committed Aug 25, 2024
1 parent c304339 commit 64639da
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
11 changes: 6 additions & 5 deletions src/app-gocardless/services/gocardless-service.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import BankFactory, { BANKS_WITH_LIMITED_HISTORY } from '../bank-factory.js';
import {
RequisitionNotLinked,
AccessDeniedError,
AccountNotLinedToRequisition,
GenericGoCardlessError,
InvalidInputDataError,
InvalidGoCardlessTokenError,
AccessDeniedError,
NotFoundError,
ResourceSuspended,
RateLimitError,
UnknownError,
ResourceSuspended,
RequisitionNotLinked,
ServiceError,
UnknownError,
} from '../errors.js';
import * as nordigenNode from 'nordigen-node';
import * as uuid from 'uuid';
Expand Down Expand Up @@ -56,7 +57,7 @@ export const handleGoCardlessError = (error) => {
case 503:
throw new ServiceError(error);
default:
return;
throw new GenericGoCardlessError(error);
}
};

Expand Down
24 changes: 11 additions & 13 deletions src/app-gocardless/services/tests/gocardless-service.spec.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { jest } from '@jest/globals';
import {
AccessDeniedError,
AccountNotLinedToRequisition,
GenericGoCardlessError,
InvalidInputDataError,
InvalidGoCardlessTokenError,
AccessDeniedError,
NotFoundError,
ResourceSuspended,
RateLimitError,
UnknownError,
ServiceError,
ResourceSuspended,
RequisitionNotLinked,
AccountNotLinedToRequisition,
ServiceError,
UnknownError,
} from '../../errors.js';

import {
Expand Down Expand Up @@ -518,13 +519,10 @@ describe('#handleGoCardlessError', () => {
expect(() => handleGoCardlessError(response)).toThrow(ServiceError);
});

it('does not throw an error for status code 200', () => {
const response = { response: { status: 200 } };
expect(() => handleGoCardlessError(response)).not.toThrow();
});

it('does not throw an error when status code is not present', () => {
const response = { foo: 'bar' };
expect(() => handleGoCardlessError(response)).not.toThrow();
it('throws a generic error when the status code is not recognised', () => {
const response = { response: { status: 0 } };
expect(() => handleGoCardlessError(response)).toThrow(
GenericGoCardlessError,
);
});
});

0 comments on commit 64639da

Please sign in to comment.