Skip to content

Commit 8127e1f

Browse files
committed
Add test for hasRequestFromCurrentAccount
1 parent 1e7fb46 commit 8127e1f

1 file changed

Lines changed: 58 additions & 0 deletions

File tree

tests/unit/ReportActionsUtilsTest.ts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,64 @@ describe('ReportActionsUtils', () => {
763763
});
764764
});
765765

766+
describe('hasRequestFromCurrentAccount', () => {
767+
const currentUserAccountID = 1242;
768+
const deletedIOUReportID = '2';
769+
const activeIOUReportID = '3';
770+
771+
const deletedIOUReportAction: ReportAction = {
772+
...LHNTestUtils.getFakeReportAction(),
773+
reportActionID: '22',
774+
actionName: CONST.REPORT.ACTIONS.TYPE.IOU,
775+
actorAccountID: currentUserAccountID,
776+
message: [
777+
{
778+
deleted: '2025-07-15 09:06:16.568',
779+
html: '',
780+
isDeletedParentAction: false,
781+
isEdited: true,
782+
text: '',
783+
type: 'COMMENT',
784+
},
785+
],
786+
};
787+
788+
const activeIOUReportAction: ReportAction = {
789+
...LHNTestUtils.getFakeReportAction(),
790+
reportActionID: '33',
791+
actionName: CONST.REPORT.ACTIONS.TYPE.IOU,
792+
actorAccountID: currentUserAccountID,
793+
message: [
794+
{
795+
deleted: '',
796+
html: '$87.00 expense',
797+
isDeletedParentAction: false,
798+
isEdited: true,
799+
text: '',
800+
type: 'COMMENT',
801+
},
802+
],
803+
};
804+
805+
beforeEach(() => {
806+
Onyx.multiSet({
807+
[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${deletedIOUReportID}`]: {[deletedIOUReportAction.reportActionID]: deletedIOUReportAction},
808+
[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${activeIOUReportID}`]: {[activeIOUReportAction.reportActionID]: activeIOUReportAction},
809+
} as unknown as KeyValueMapping);
810+
return waitForBatchedUpdates();
811+
});
812+
813+
it('should return false for a deleted IOU report action', () => {
814+
const result = ReportActionsUtils.hasRequestFromCurrentAccount(deletedIOUReportID, currentUserAccountID);
815+
expect(result).toBe(false);
816+
});
817+
818+
it('should return true for an active IOU report action', () => {
819+
const result = ReportActionsUtils.hasRequestFromCurrentAccount(activeIOUReportID, currentUserAccountID);
820+
expect(result).toBe(true);
821+
});
822+
});
823+
766824
describe('getLastVisibleAction', () => {
767825
it('should return the last visible action for a report', () => {
768826
const report: Report = {

0 commit comments

Comments
 (0)