From 267de9d0c6c56d0657a9de6c36774b8d44165abb Mon Sep 17 00:00:00 2001 From: Youssef Lourayad Date: Fri, 1 Mar 2024 02:18:34 +0100 Subject: [PATCH] Update tests --- tests/unit/ReportUtilsTest.js | 39 +++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/tests/unit/ReportUtilsTest.js b/tests/unit/ReportUtilsTest.js index a5b0a5d3c151..f8c830c8f3c8 100644 --- a/tests/unit/ReportUtilsTest.js +++ b/tests/unit/ReportUtilsTest.js @@ -410,24 +410,27 @@ describe('ReportUtils', () => { }); }); - it("it is a non-open expense report tied to user's own paid policy expense chat", () => { + it("it is a submitted report tied to user's own policy expense chat and the policy has Instant Submit frequency", () => { Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}101`, { reportID: '101', chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT, isOwnPolicyExpenseChat: true, }).then(() => { + const paidPolicy = { + id: '3f54cca8', + type: CONST.POLICY.TYPE.TEAM, + autoReportingFrequency: CONST.POLICY.AUTO_REPORTING_FREQUENCIES.INSTANT, + }; const report = { ...LHNTestUtils.getFakeReport(), type: CONST.REPORT.TYPE.EXPENSE, stateNum: CONST.REPORT.STATE_NUM.SUBMITTED, statusNum: CONST.REPORT.STATUS_NUM.SUBMITTED, parentReportID: '101', - }; - const paidPolicy = { - type: CONST.POLICY.TYPE.TEAM, + policyID: paidPolicy.id, }; const moneyRequestOptions = ReportUtils.getMoneyRequestOptions(report, paidPolicy, [currentUserAccountID, participantsAccountIDs[0]]); - expect(moneyRequestOptions.length).toBe(0); + expect(moneyRequestOptions.length).toBe(1); }); }); }); @@ -498,7 +501,7 @@ describe('ReportUtils', () => { }); }); - it("it is an open expense report tied to user's own paid policy expense chat", () => { + it("it is an open expense report tied to user's own policy expense chat", () => { Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}103`, { reportID: '103', chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT, @@ -542,6 +545,30 @@ describe('ReportUtils', () => { expect(moneyRequestOptions.length).toBe(1); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.REQUEST)).toBe(true); }); + + it("it is a submitted expense report in user's own policyExpenseChat and the policy has Instant Submit frequency", () => { + Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}101`, { + reportID: '101', + chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT, + isOwnPolicyExpenseChat: true, + }).then(() => { + const paidPolicy = { + id: 'ef72dfeb', + type: CONST.POLICY.TYPE.TEAM, + autoReportingFrequency: CONST.POLICY.AUTO_REPORTING_FREQUENCIES.INSTANT, + }; + const report = { + ...LHNTestUtils.getFakeReport(), + type: CONST.REPORT.TYPE.EXPENSE, + stateNum: CONST.REPORT.STATE_NUM.SUBMITTED, + statusNum: CONST.REPORT.STATUS_NUM.SUBMITTED, + parentReportID: '101', + policyID: paidPolicy.id, + }; + const moneyRequestOptions = ReportUtils.getMoneyRequestOptions(report, paidPolicy, [currentUserAccountID, participantsAccountIDs[0]]); + expect(moneyRequestOptions.length).toBe(1); + }); + }); }); describe('return multiple money request option if', () => {