From 36bb786864dce8ddb7d7bd385655a48531aeadb1 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Thu, 28 Nov 2024 16:03:24 +0700 Subject: [PATCH] fix: add test for cancel payment --- tests/actions/IOUTest.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/actions/IOUTest.ts b/tests/actions/IOUTest.ts index 4430ec0ce052..9b34578bbc66 100644 --- a/tests/actions/IOUTest.ts +++ b/tests/actions/IOUTest.ts @@ -1675,6 +1675,28 @@ describe('actions/IOU', () => { ); expect(payIOUAction).toBeTruthy(); + resolve(); + }, + }); + }), + ) + .then(() => { + mockFetch?.pause?.(); + if (chatReport && iouReport) { + IOU.cancelPayment(iouReport, chatReport); + } + return waitForBatchedUpdates(); + }) + .then( + () => + new Promise((resolve) => { + const connection = Onyx.connect({ + key: ONYXKEYS.COLLECTION.REPORT, + waitForCollectionCallback: true, + callback: (allReports) => { + Onyx.disconnect(connection); + const chatReportData = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${chatReport?.reportID}`]; + expect(chatReportData?.iouReportID).toBe(iouReport?.reportID); resolve(); }, });