Skip to content

Commit c2555d9

Browse files
committed
fix IOUTest
1 parent dbcfb81 commit c2555d9

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

tests/actions/IOUTest.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {format} from 'date-fns';
33
import {deepEqual} from 'fast-equals';
44
import type {OnyxCollection, OnyxEntry, OnyxInputValue} from 'react-native-onyx';
55
import Onyx from 'react-native-onyx';
6+
import OnyxProvider from '@components/OnyxProvider';
67
import useReportWithTransactionsAndViolations from '@hooks/useReportWithTransactionsAndViolations';
78
import {
89
addSplitExpenseField,
@@ -33,6 +34,7 @@ import {
3334
updateMoneyRequestCategory,
3435
updateSplitExpenseAmountField,
3536
} from '@libs/actions/IOU';
37+
import initOnyxDerivedValues from '@libs/actions/OnyxDerived';
3638
import {createWorkspace, deleteWorkspace, generatePolicyID, setWorkspaceApprovalMode} from '@libs/actions/Policy/Policy';
3739
import {addComment, createNewReport, deleteReport, notifyNewAction, openReport} from '@libs/actions/Report';
3840
import {clearAllRelatedReportActionErrors} from '@libs/actions/ReportActions';
@@ -151,6 +153,7 @@ describe('actions/IOU', () => {
151153
[ONYXKEYS.PERSONAL_DETAILS_LIST]: {[RORY_ACCOUNT_ID]: {accountID: RORY_ACCOUNT_ID, login: RORY_EMAIL}},
152154
},
153155
});
156+
initOnyxDerivedValues();
154157
IntlStore.load(CONST.LOCALES.EN);
155158
return waitForBatchedUpdates();
156159
});
@@ -5204,7 +5207,8 @@ describe('actions/IOU', () => {
52045207

52055208
expect(canApproveIOU(fakeReport, fakePolicy)).toBeFalsy();
52065209
// Then should return false when passing transactions directly as the third parameter instead of relying on Onyx data
5207-
const {result} = renderHook(() => useReportWithTransactionsAndViolations(reportID));
5210+
const {result} = renderHook(() => useReportWithTransactionsAndViolations(reportID), {wrapper: OnyxProvider});
5211+
await waitForBatchedUpdates();
52085212
expect(canApproveIOU(result.current.at(0) as Report, fakePolicy, result.current.at(1) as Transaction[])).toBeFalsy();
52095213
});
52105214
it('should return false if we have only scan failure transactions', async () => {
@@ -5259,7 +5263,8 @@ describe('actions/IOU', () => {
52595263

52605264
expect(canApproveIOU(fakeReport, fakePolicy)).toBeFalsy();
52615265
// Then should return false when passing transactions directly as the third parameter instead of relying on Onyx data
5262-
const {result} = renderHook(() => useReportWithTransactionsAndViolations(reportID));
5266+
const {result} = renderHook(() => useReportWithTransactionsAndViolations(reportID), {wrapper: OnyxProvider});
5267+
await waitForBatchedUpdates();
52635268
expect(canApproveIOU(result.current.at(0) as Report, fakePolicy, result.current.at(1) as Transaction[])).toBeFalsy();
52645269
});
52655270
it('should return false if all transactions are pending card or scan failure transaction', async () => {
@@ -5305,7 +5310,8 @@ describe('actions/IOU', () => {
53055310

53065311
expect(canApproveIOU(fakeReport, fakePolicy)).toBeFalsy();
53075312
// Then should return false when passing transactions directly as the third parameter instead of relying on Onyx data
5308-
const {result} = renderHook(() => useReportWithTransactionsAndViolations(reportID));
5313+
const {result} = renderHook(() => useReportWithTransactionsAndViolations(reportID), {wrapper: OnyxProvider});
5314+
await waitForBatchedUpdates();
53095315
expect(canApproveIOU(result.current.at(0) as Report, fakePolicy, result.current.at(1) as Transaction[])).toBeFalsy();
53105316
});
53115317
it('should return true if at least one transactions is not pending card or scan failure transaction', async () => {
@@ -5356,7 +5362,8 @@ describe('actions/IOU', () => {
53565362

53575363
expect(canApproveIOU(fakeReport, fakePolicy)).toBeTruthy();
53585364
// Then should return true when passing transactions directly as the third parameter instead of relying on Onyx data
5359-
const {result} = renderHook(() => useReportWithTransactionsAndViolations(reportID));
5365+
const {result} = renderHook(() => useReportWithTransactionsAndViolations(reportID), {wrapper: OnyxProvider});
5366+
await waitForBatchedUpdates();
53605367
expect(canApproveIOU(result.current.at(0) as Report, fakePolicy, result.current.at(1) as Transaction[])).toBeTruthy();
53615368
});
53625369

0 commit comments

Comments
 (0)