From 9d8e980518e2ea03e7bd67eae5322895ce568e27 Mon Sep 17 00:00:00 2001 From: Prashant Bajpai <34747455+prashantasdeveloper@users.noreply.github.com> Date: Tue, 30 Jul 2024 14:41:04 +0530 Subject: [PATCH] =?UTF-8?q?test:=20=F0=9F=92=8D=20Add=20tests=20to=20bump?= =?UTF-8?q?=20coverage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../confidential-transactions.service.spec.ts | 5 ++++- src/transactions/transactions.util.spec.ts | 10 ++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/confidential-transactions/confidential-transactions.service.spec.ts b/src/confidential-transactions/confidential-transactions.service.spec.ts index 0904c624..2ed29d64 100644 --- a/src/confidential-transactions/confidential-transactions.service.spec.ts +++ b/src/confidential-transactions/confidential-transactions.service.spec.ts @@ -117,7 +117,10 @@ describe('ConfidentialTransactionsService', () => { await expect(() => service.findOne(id)).rejects.toThrowError(); - expect(handleSdkErrorSpy).toHaveBeenCalledWith(mockError); + expect(handleSdkErrorSpy).toHaveBeenCalledWith(mockError, { + id: id.toString(), + resource: 'Confidential Transaction', + }); }); }); diff --git a/src/transactions/transactions.util.spec.ts b/src/transactions/transactions.util.spec.ts index 5919c05b..ee589130 100644 --- a/src/transactions/transactions.util.spec.ts +++ b/src/transactions/transactions.util.spec.ts @@ -228,4 +228,14 @@ describe('handleSdkError', () => { expect(error).toBeInstanceOf(expectedError); }); }); + it('should return AppNotFoundError with resource specific info', () => { + const inputError = new PolymeshError({ code: ErrorCode.DataUnavailable, message: '' }); + when(mockIsPolymeshError).calledWith(inputError).mockReturnValue(true); + const error = handleSdkError(inputError, { id: '1', resource: 'Example Resource' }); + + expect(error).toBeInstanceOf(AppNotFoundError); + expect(error.message).toEqual( + 'Not Found: Example Resource was not found: with identifier: "1"' + ); + }); });