Skip to content

Commit

Permalink
Refactor old names in nav tests
Browse files Browse the repository at this point in the history
  • Loading branch information
WojtekBoman committed Jan 10, 2025
1 parent 3d9bd3f commit c7cc789
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
10 changes: 5 additions & 5 deletions tests/navigation/GoBackTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {act, render} from '@testing-library/react-native';
import React from 'react';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import getIsNarrowLayout from '@libs/getIsNarrowLayout';
import createResponsiveStackNavigator from '@libs/Navigation/AppNavigator/createResponsiveStackNavigator';
import createRootStackNavigator from '@libs/Navigation/AppNavigator/createRootStackNavigator';
import createSplitNavigator from '@libs/Navigation/AppNavigator/createSplitNavigator';
import Navigation from '@libs/Navigation/Navigation';
import navigationRef from '@libs/Navigation/navigationRef';
Expand All @@ -14,7 +14,7 @@ import NAVIGATORS from '@src/NAVIGATORS';
import ROUTES from '@src/ROUTES';
import SCREENS from '@src/SCREENS';

const RootStack = createResponsiveStackNavigator<AuthScreensParamList>();
const RootStack = createRootStackNavigator<AuthScreensParamList>();
const ReportsSplit = createSplitNavigator<ReportsSplitNavigatorParamList>();
const SettingsSplit = createSplitNavigator<SettingsSplitNavigatorParamList>();

Expand Down Expand Up @@ -90,7 +90,7 @@ function TestNavigationContainer({initialState}: TestNavigationContainerProps) {
component={SettingsSplitNavigator}
/>
<RootStack.Screen
name={SCREENS.SEARCH.CENTRAL_PANE}
name={SCREENS.SEARCH.ROOT}
getComponent={() => jest.fn()}
/>
</RootStack.Navigator>
Expand Down Expand Up @@ -340,7 +340,7 @@ describe('Go back on the narrow layout', () => {
},
},
{
name: SCREENS.SEARCH.CENTRAL_PANE,
name: SCREENS.SEARCH.ROOT,
},
],
}}
Expand All @@ -349,7 +349,7 @@ describe('Go back on the narrow layout', () => {

const rootStateBeforeGoBack = navigationRef.current?.getRootState();
expect(rootStateBeforeGoBack?.index).toBe(2);
expect(rootStateBeforeGoBack?.routes.at(-1)?.name).toBe(SCREENS.SEARCH.CENTRAL_PANE);
expect(rootStateBeforeGoBack?.routes.at(-1)?.name).toBe(SCREENS.SEARCH.ROOT);

// When go back to the page present in the split navigator that is more than 1 route away
act(() => {
Expand Down
10 changes: 5 additions & 5 deletions tests/navigation/NavigateTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {act, render} from '@testing-library/react-native';
import React from 'react';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import getIsNarrowLayout from '@libs/getIsNarrowLayout';
import createResponsiveStackNavigator from '@libs/Navigation/AppNavigator/createResponsiveStackNavigator';
import createRootStackNavigator from '@libs/Navigation/AppNavigator/createRootStackNavigator';
import createSplitNavigator from '@libs/Navigation/AppNavigator/createSplitNavigator';
import Navigation from '@libs/Navigation/Navigation';
import navigationRef from '@libs/Navigation/navigationRef';
Expand All @@ -14,7 +14,7 @@ import NAVIGATORS from '@src/NAVIGATORS';
import ROUTES from '@src/ROUTES';
import SCREENS from '@src/SCREENS';

const RootStack = createResponsiveStackNavigator<AuthScreensParamList>();
const RootStack = createRootStackNavigator<AuthScreensParamList>();
const ReportsSplit = createSplitNavigator<ReportsSplitNavigatorParamList>();
const SettingsSplit = createSplitNavigator<SettingsSplitNavigatorParamList>();

Expand Down Expand Up @@ -90,7 +90,7 @@ function TestNavigationContainer({initialState}: TestNavigationContainerProps) {
component={SettingsSplitNavigator}
/>
<RootStack.Screen
name={SCREENS.SEARCH.CENTRAL_PANE}
name={SCREENS.SEARCH.ROOT}
getComponent={() => jest.fn()}
/>
</RootStack.Navigator>
Expand Down Expand Up @@ -233,7 +233,7 @@ describe('Navigate', () => {
index: 0,
routes: [
{
name: SCREENS.SEARCH.CENTRAL_PANE,
name: SCREENS.SEARCH.ROOT,
params: {
q: 'type:expense status:all sortBy:date sortOrder:desc policyID:1',
},
Expand All @@ -246,7 +246,7 @@ describe('Navigate', () => {
const rootStateBeforeNavigate = navigationRef.current?.getRootState();
const lastSplitBeforeNavigate = rootStateBeforeNavigate?.routes.at(-1);
expect(rootStateBeforeNavigate?.index).toBe(0);
expect(lastSplitBeforeNavigate?.name).toBe(SCREENS.SEARCH.CENTRAL_PANE);
expect(lastSplitBeforeNavigate?.name).toBe(SCREENS.SEARCH.ROOT);

// When navigate to the Home page when the active workspace is set
act(() => {
Expand Down
18 changes: 9 additions & 9 deletions tests/navigation/SwitchPolicyIDTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {act, render} from '@testing-library/react-native';
import React from 'react';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import getIsNarrowLayout from '@libs/getIsNarrowLayout';
import createResponsiveStackNavigator from '@libs/Navigation/AppNavigator/createResponsiveStackNavigator';
import createRootStackNavigator from '@libs/Navigation/AppNavigator/createRootStackNavigator';
import createSplitNavigator from '@libs/Navigation/AppNavigator/createSplitNavigator';
import navigationRef from '@libs/Navigation/navigationRef';
import type {AuthScreensParamList, ReportsSplitNavigatorParamList} from '@libs/Navigation/types';
Expand All @@ -13,7 +13,7 @@ import CONST from '@src/CONST';
import NAVIGATORS from '@src/NAVIGATORS';
import SCREENS from '@src/SCREENS';

const RootStack = createResponsiveStackNavigator<AuthScreensParamList>();
const RootStack = createRootStackNavigator<AuthScreensParamList>();
const ReportsSplit = createSplitNavigator<ReportsSplitNavigatorParamList>();

jest.mock('@hooks/useResponsiveLayout', () => jest.fn());
Expand Down Expand Up @@ -57,7 +57,7 @@ function TestNavigationContainer({initialState}: TestNavigationContainerProps) {
component={ReportsSplitNavigator}
/>
<RootStack.Screen
name={SCREENS.SEARCH.CENTRAL_PANE}
name={SCREENS.SEARCH.ROOT}
getComponent={() => jest.fn()}
/>
</RootStack.Navigator>
Expand Down Expand Up @@ -126,7 +126,7 @@ describe('Switch policy ID', () => {
index: 0,
routes: [
{
name: SCREENS.SEARCH.CENTRAL_PANE,
name: SCREENS.SEARCH.ROOT,
params: {
q: 'type:expense status:all sortBy:date sortOrder:desc',
},
Expand All @@ -139,7 +139,7 @@ describe('Switch policy ID', () => {
const rootStateBeforeSwitch = navigationRef.current?.getRootState();
expect(rootStateBeforeSwitch?.index).toBe(0);
const lastRouteBeforeSwitch = rootStateBeforeSwitch?.routes?.at(-1);
expect(lastRouteBeforeSwitch?.name).toBe(SCREENS.SEARCH.CENTRAL_PANE);
expect(lastRouteBeforeSwitch?.name).toBe(SCREENS.SEARCH.ROOT);
expect(lastRouteBeforeSwitch?.params).toMatchObject({q: 'type:expense status:all sortBy:date sortOrder:desc'});

// When switch to the specific policy from the Search page
Expand All @@ -151,7 +151,7 @@ describe('Switch policy ID', () => {
const rootStateAfterSwitch = navigationRef.current?.getRootState();
expect(rootStateAfterSwitch?.index).toBe(1);
const lastRouteAfterSwitch = rootStateAfterSwitch?.routes?.at(-1);
expect(lastRouteAfterSwitch?.name).toBe(SCREENS.SEARCH.CENTRAL_PANE);
expect(lastRouteAfterSwitch?.name).toBe(SCREENS.SEARCH.ROOT);
expect(lastRouteAfterSwitch?.params).toMatchObject({q: 'type:expense status:all sortBy:date sortOrder:desc policyID:1'});
});
});
Expand Down Expand Up @@ -212,7 +212,7 @@ describe('Switch policy ID', () => {
index: 0,
routes: [
{
name: SCREENS.SEARCH.CENTRAL_PANE,
name: SCREENS.SEARCH.ROOT,
params: {
q: 'type:expense status:all sortBy:date sortOrder:desc policyID:1',
},
Expand All @@ -225,7 +225,7 @@ describe('Switch policy ID', () => {
const rootStateBeforeSwitch = navigationRef.current?.getRootState();
expect(rootStateBeforeSwitch?.index).toBe(0);
const lastRouteBeforeSwitch = rootStateBeforeSwitch?.routes?.at(-1);
expect(lastRouteBeforeSwitch?.name).toBe(SCREENS.SEARCH.CENTRAL_PANE);
expect(lastRouteBeforeSwitch?.name).toBe(SCREENS.SEARCH.ROOT);
expect(lastRouteBeforeSwitch?.params).toMatchObject({q: 'type:expense status:all sortBy:date sortOrder:desc policyID:1'});

// When switch policy to the global from the Search page
Expand All @@ -237,7 +237,7 @@ describe('Switch policy ID', () => {
const rootStateAfterSwitch = navigationRef.current?.getRootState();
expect(rootStateAfterSwitch?.index).toBe(1);
const lastRouteAfterSwitch = rootStateAfterSwitch?.routes?.at(-1);
expect(lastRouteAfterSwitch?.name).toBe(SCREENS.SEARCH.CENTRAL_PANE);
expect(lastRouteAfterSwitch?.name).toBe(SCREENS.SEARCH.ROOT);
expect(lastRouteAfterSwitch?.params).toMatchObject({q: 'type:expense status:all sortBy:date sortOrder:desc'});
});
});
Expand Down

0 comments on commit c7cc789

Please sign in to comment.