Skip to content

Commit a6550bf

Browse files
committed
update test
1 parent 606e084 commit a6550bf

1 file changed

Lines changed: 17 additions & 13 deletions

File tree

tests/ui/ReportActionsViewTest.tsx

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as NativeNavigation from '@react-navigation/native';
1+
import type * as ReactNavigation from '@react-navigation/native';
22
import {render, screen} from '@testing-library/react-native';
33
import React from 'react';
44
import Onyx from 'react-native-onyx';
@@ -13,13 +13,20 @@ import ONYXKEYS from '@src/ONYXKEYS';
1313
import type * as OnyxTypes from '@src/types/onyx';
1414
import waitForBatchedUpdatesWithAct from '../utils/waitForBatchedUpdatesWithAct';
1515

16-
jest.mock('@react-navigation/native');
17-
const mockUseIsFocused = jest.fn(() => true);
18-
const mockUseRoute = jest.fn(() => ({
19-
params: {},
20-
}));
21-
(NativeNavigation as any).useIsFocused = mockUseIsFocused;
22-
(NativeNavigation as any).useRoute = mockUseRoute;
16+
const mockUseIsFocused = jest.fn().mockReturnValue(false);
17+
jest.mock('@react-navigation/native', () => {
18+
const actualNav = jest.requireActual<typeof ReactNavigation>('@react-navigation/native');
19+
return {
20+
...actualNav,
21+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
22+
useIsFocused: () => mockUseIsFocused(),
23+
useRoute: jest.fn(),
24+
useNavigationState: jest.fn(),
25+
createNavigationContainerRef: () => ({
26+
getState: () => jest.fn(),
27+
}),
28+
};
29+
});
2330

2431
jest.mock('@hooks/useNetwork', () => jest.fn());
2532
jest.mock('@hooks/useOnyx', () => jest.fn());
@@ -40,7 +47,7 @@ jest.mock('@hooks/useLoadReportActions', () =>
4047
jest.mock('@hooks/usePrevious', () => jest.fn());
4148

4249
jest.mock('@pages/home/report/ReportActionsList', () =>
43-
jest.fn(({sortedReportActions}) => {
50+
jest.fn(({sortedReportActions}: {sortedReportActions: OnyxTypes.ReportAction[]}) => {
4451
if (sortedReportActions && sortedReportActions.length > 0) {
4552
return null; // Simulate normal content
4653
}
@@ -53,10 +60,6 @@ jest.mock('@libs/actions/Report', () => ({
5360
updateLoadingInitialReportAction: jest.fn(),
5461
}));
5562

56-
jest.mock('@libs/Performance', () => ({
57-
withRenderTrace: jest.fn(() => (Component: any) => Component),
58-
}));
59-
6063
// Mock report data
6164
const mockReport: OnyxTypes.Report = {
6265
reportID: '123',
@@ -115,6 +118,7 @@ const renderReportActionsView = (
115118
...props,
116119
};
117120

121+
// eslint-disable-next-line react/jsx-props-no-spreading
118122
return render(<ReportActionsView {...defaultProps} />);
119123
};
120124

0 commit comments

Comments
 (0)