Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
adamgrzybowski committed Jan 10, 2025
1 parent b21cb6a commit 6589e68
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
10 changes: 10 additions & 0 deletions tests/ui/LHNItemsPresence.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type * as reactNavigationNativeImport from '@react-navigation/native';
import {screen} from '@testing-library/react-native';
import type {ComponentType} from 'react';
import Onyx from 'react-native-onyx';
Expand All @@ -24,6 +25,15 @@ import wrapOnyxWithWaitForBatchedUpdates from '../utils/wrapOnyxWithWaitForBatch
jest.mock('@libs/Permissions');
jest.mock('@hooks/useActiveWorkspace', () => jest.fn(() => ({activeWorkspaceID: undefined})));

jest.mock('@react-navigation/native', () => ({
...jest.requireActual<typeof reactNavigationNativeImport>('@react-navigation/native'),
useNavigationState: () => undefined,
useIsFocused: () => true,
useRoute: () => ({name: 'Home'}),
useNavigation: () => undefined,
useFocusEffect: () => undefined,
}));

type LazyLoadLHNTestUtils = {
fakePersonalDetails: PersonalDetailsList;
};
Expand Down
10 changes: 5 additions & 5 deletions tests/ui/WorkspaceCategoriesTest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {CurrentReportIDContextProvider} from '@hooks/useCurrentReportID';
import * as useResponsiveLayoutModule from '@hooks/useResponsiveLayout';
import type ResponsiveLayoutResult from '@hooks/useResponsiveLayout/types';
import * as Localize from '@libs/Localize';
import createSplitNavigator from '@libs/Navigation/AppNavigator/createSplitNavigator';
import createPlatformStackNavigator from '@libs/Navigation/PlatformStackNavigation/createPlatformStackNavigator';
import type {WorkspaceSplitNavigatorParamList} from '@navigation/types';
import WorkspaceCategoriesPage from '@pages/workspace/categories/WorkspaceCategoriesPage';
import CONST from '@src/CONST';
Expand All @@ -22,20 +22,20 @@ import waitForBatchedUpdatesWithAct from '../utils/waitForBatchedUpdatesWithAct'

TestHelper.setupGlobalFetchMock();

const Split = createSplitNavigator<WorkspaceSplitNavigatorParamList>();
const Stack = createPlatformStackNavigator<WorkspaceSplitNavigatorParamList>();

const renderPage = (initialRouteName: typeof SCREENS.WORKSPACE.CATEGORIES, initialParams: WorkspaceSplitNavigatorParamList[typeof SCREENS.WORKSPACE.CATEGORIES]) => {
return render(
<ComposeProviders components={[OnyxProvider, LocaleContextProvider, CurrentReportIDContextProvider]}>
<PortalProvider>
<NavigationContainer>
<Split.Navigator initialRouteName={initialRouteName}>
<Split.Screen
<Stack.Navigator initialRouteName={initialRouteName}>
<Stack.Screen
name={SCREENS.WORKSPACE.CATEGORIES}
component={WorkspaceCategoriesPage}
initialParams={initialParams}
/>
</Split.Navigator>
</Stack.Navigator>
</NavigationContainer>
</PortalProvider>
</ComposeProviders>,
Expand Down

0 comments on commit 6589e68

Please sign in to comment.