Skip to content

Commit

Permalink
remove redundant tests
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-fidd committed Aug 20, 2024
1 parent dc92b6e commit 31f0cd3
Showing 1 changed file with 9 additions and 102 deletions.
111 changes: 9 additions & 102 deletions src/app-gocardless/services/tests/gocardless-service.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,17 +252,6 @@ describe('goCardlessService', () => {

expect(createRequisitionSpy).toBeCalledTimes(1);
});

it('handle error if status_code present in the response', async () => {
setTokenSpy.mockResolvedValue();
getInstitutionSpy.mockResolvedValue(mockInstitution);

createRequisitionSpy.mockResolvedValue(mockUnknownError);

await expect(() =>
goCardlessService.createRequisition(params),
).rejects.toThrow(UnknownError);
});
});

describe('#deleteRequisition', () => {
Expand All @@ -281,17 +270,6 @@ describe('goCardlessService', () => {
expect(getRequisitionsSpy).toBeCalledTimes(1);
expect(deleteRequisitionsSpy).toBeCalledTimes(1);
});

it('handle error if status_code present in the response', async () => {
setTokenSpy.mockResolvedValue();

getRequisitionsSpy.mockResolvedValue(mockRequisition);
deleteRequisitionsSpy.mockReturnValue(mockUnknownError);

await expect(() =>
goCardlessService.deleteRequisition(requisitionId),
).rejects.toThrow(UnknownError);
});
});

describe('#getRequisition', () => {
Expand All @@ -308,16 +286,6 @@ describe('goCardlessService', () => {
expect(setTokenSpy).toBeCalledTimes(1);
expect(getRequisitionsSpy).toBeCalledTimes(1);
});

it('handle error if status_code present in the response', async () => {
setTokenSpy.mockResolvedValue();

getRequisitionsSpy.mockReturnValue(mockUnknownError);

await expect(() =>
goCardlessService.getRequisition(requisitionId),
).rejects.toThrow(UnknownError);
});
});

describe('#getDetailedAccount', () => {
Expand All @@ -332,30 +300,6 @@ describe('goCardlessService', () => {
expect(getDetailsSpy).toBeCalledTimes(1);
expect(getMetadataSpy).toBeCalledTimes(1);
});

it('handle error if status_code present in the detailedAccount response', async () => {
getDetailsSpy.mockResolvedValue(mockUnknownError);
getMetadataSpy.mockResolvedValue(mockAccountMetaData);

await expect(() =>
goCardlessService.getDetailedAccount(accountId),
).rejects.toThrow(UnknownError);

expect(getDetailsSpy).toBeCalledTimes(1);
expect(getMetadataSpy).toBeCalledTimes(1);
});

it('handle error if status_code present in the metadataAccount response', async () => {
getDetailsSpy.mockResolvedValue(mockAccountDetails);
getMetadataSpy.mockResolvedValue(mockUnknownError);

await expect(() =>
goCardlessService.getDetailedAccount(accountId),
).rejects.toThrow(UnknownError);

expect(getDetailsSpy).toBeCalledTimes(1);
expect(getMetadataSpy).toBeCalledTimes(1);
});
});

describe('#getInstitutions', () => {
Expand All @@ -368,14 +312,6 @@ describe('goCardlessService', () => {
]);
expect(getInstitutionsSpy).toBeCalledTimes(1);
});

it('handle error if status_code present in the response', async () => {
getInstitutionsSpy.mockResolvedValue(mockUnknownError);

await expect(() =>
goCardlessService.getInstitutions({ country }),
).rejects.toThrow(UnknownError);
});
});

describe('#getInstitution', () => {
Expand All @@ -388,14 +324,6 @@ describe('goCardlessService', () => {
);
expect(getInstitutionSpy).toBeCalledTimes(1);
});

it('handle error if status_code present in the response', async () => {
getInstitutionSpy.mockResolvedValue(mockUnknownError);

await expect(() =>
goCardlessService.getInstitution(institutionId),
).rejects.toThrow(UnknownError);
});
});

describe('#extendAccountsAboutInstitutions', () => {
Expand Down Expand Up @@ -532,19 +460,6 @@ describe('goCardlessService', () => {
`);
expect(getTransactionsSpy).toBeCalledTimes(1);
});

it('handle error if status_code present in the response', async () => {
getTransactionsSpy.mockResolvedValue(mockUnknownError);

await expect(() =>
goCardlessService.getTransactions({
institutionId: 'SANDBOXFINANCE_SFIN0000',
accountId,
startDate: '',
endDate: '',
}),
).rejects.toThrow(UnknownError);
});
});

describe('#getBalances', () => {
Expand All @@ -556,64 +471,56 @@ describe('goCardlessService', () => {
);
expect(getBalancesSpy).toBeCalledTimes(1);
});

it('handle error if status_code present in the response', async () => {
getBalancesSpy.mockResolvedValue(mockUnknownError);

await expect(() =>
goCardlessService.getBalances(accountId),
).rejects.toThrow(UnknownError);
});
});
});

describe('#handleGoCardlessError', () => {
it('throws InvalidInputDataError for status code 400', () => {
const response = { status_code: 400 };
const response = { response: { status: 400 }};

Check failure on line 479 in src/app-gocardless/services/tests/gocardless-service.spec.js

View workflow job for this annotation

GitHub Actions / lint

Insert `·`
expect(() => handleGoCardlessError(response)).toThrow(
InvalidInputDataError,
);
});

it('throws InvalidGoCardlessTokenError for status code 401', () => {
const response = { status_code: 401 };
const response = { response: { status: 401 }};

Check failure on line 486 in src/app-gocardless/services/tests/gocardless-service.spec.js

View workflow job for this annotation

GitHub Actions / lint

Insert `·`
expect(() => handleGoCardlessError(response)).toThrow(
InvalidGoCardlessTokenError,
);
});

it('throws AccessDeniedError for status code 403', () => {
const response = { status_code: 403 };
const response = { response: { status: 403 }};

Check failure on line 493 in src/app-gocardless/services/tests/gocardless-service.spec.js

View workflow job for this annotation

GitHub Actions / lint

Insert `·`
expect(() => handleGoCardlessError(response)).toThrow(AccessDeniedError);
});

it('throws NotFoundError for status code 404', () => {
const response = { status_code: 404 };
const response = { response: { status: 404 }};

Check failure on line 498 in src/app-gocardless/services/tests/gocardless-service.spec.js

View workflow job for this annotation

GitHub Actions / lint

Insert `·`
expect(() => handleGoCardlessError(response)).toThrow(NotFoundError);
});

it('throws ResourceSuspended for status code 409', () => {
const response = { status_code: 409 };
const response = { response: { status: 409 }};

Check failure on line 503 in src/app-gocardless/services/tests/gocardless-service.spec.js

View workflow job for this annotation

GitHub Actions / lint

Insert `·`
expect(() => handleGoCardlessError(response)).toThrow(ResourceSuspended);
});

it('throws RateLimitError for status code 429', () => {
const response = { status_code: 429 };
const response = { response: { status: 429 }};

Check failure on line 508 in src/app-gocardless/services/tests/gocardless-service.spec.js

View workflow job for this annotation

GitHub Actions / lint

Insert `·`
expect(() => handleGoCardlessError(response)).toThrow(RateLimitError);
});

it('throws UnknownError for status code 500', () => {
const response = { status_code: 500 };
const response = { response: { status: 500 }};

Check failure on line 513 in src/app-gocardless/services/tests/gocardless-service.spec.js

View workflow job for this annotation

GitHub Actions / lint

Insert `·`
expect(() => handleGoCardlessError(response)).toThrow(UnknownError);
});

it('throws ServiceError for status code 503', () => {
const response = { status_code: 503 };
const response = { response: { status: 503 }};

Check failure on line 518 in src/app-gocardless/services/tests/gocardless-service.spec.js

View workflow job for this annotation

GitHub Actions / lint

Insert `·`
expect(() => handleGoCardlessError(response)).toThrow(ServiceError);
});

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

Check failure on line 523 in src/app-gocardless/services/tests/gocardless-service.spec.js

View workflow job for this annotation

GitHub Actions / lint

Insert `·`
expect(() => handleGoCardlessError(response)).not.toThrow();
});

Expand Down

0 comments on commit 31f0cd3

Please sign in to comment.