Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,14 @@ const renderWithReduxProvider = (component: React.ReactElement) =>

const mockSetOptions = jest.fn();
const mockNavigate = jest.fn();
const mockNavigationDispatch = jest.fn();
let mockRouteParams: { type: 'source' | 'dest' } = { type: 'source' };

jest.mock('@react-navigation/native', () => ({
...jest.requireActual('@react-navigation/native'),
useNavigation: () => ({
navigate: mockNavigate,
dispatch: mockNavigationDispatch,
goBack: jest.fn(),
setOptions: mockSetOptions,
}),
Expand Down Expand Up @@ -399,6 +401,7 @@ const resetMocks = () => {
mockSelectedToken = null;
mockFormatAddressToAssetId.mockReturnValue('eip155:1/erc20:0x1234');
mockIsNonEvmChainId.mockReturnValue(false);
mockNavigationDispatch.mockReset();
};

describe('tokenToIncludeAsset', () => {
Expand Down Expand Up @@ -690,15 +693,21 @@ describe('BridgeTokenSelector', () => {
await act(async () => {
fireEvent.press(getByTestId('button-icon-info'));
});
expect(mockNavigate).toHaveBeenCalledWith(
'Asset',
expect(mockNavigationDispatch).toHaveBeenCalledWith(
expect.objectContaining({
symbol: 'USDC',
name: 'USD Coin',
assetId: 'eip155:1/erc20:0x1234567890123456789012345678901234567890',
chainId: '0x1',
decimals: 18,
image: 'https://example.com/token.png',
type: 'PUSH',
payload: expect.objectContaining({
name: 'Asset',
params: expect.objectContaining({
symbol: 'USDC',
name: 'USD Coin',
assetId:
'eip155:1/erc20:0x1234567890123456789012345678901234567890',
chainId: '0x1',
decimals: 18,
image: 'https://example.com/token.png',
}),
}),
}),
);
expect(mockTrackEvent).toHaveBeenCalled();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ import {
ListRenderItemInfo,
} from 'react-native';
import { SafeAreaView } from 'react-native-safe-area-context';
import { useNavigation, useRoute, RouteProp } from '@react-navigation/native';
import {
useNavigation,
useRoute,
RouteProp,
StackActions,
} from '@react-navigation/native';
import { useSelector, useDispatch } from 'react-redux';
import { strings } from '../../../../../../locales/i18n';
import { getHeaderCompactStandardNavbarOptions } from '../../../../../component-library/components-temp/HeaderCompactStandard';
Expand Down Expand Up @@ -371,10 +376,14 @@ export const BridgeTokenSelector: React.FC = () => {
);
const networkName = chainData?.name ?? '';

navigation.navigate('Asset', {
...item,
source: TokenDetailsSource.Swap,
});
// Use push so we always open details for the tapped token.
// navigate('Asset') can reuse an existing Asset route with stale params.
navigation.dispatch(
StackActions.push('Asset', {
...item,
source: TokenDetailsSource.Swap,
}),
);

Engine.context.BridgeController.trackUnifiedSwapBridgeEvent(
UnifiedSwapBridgeEventName.AssetDetailTooltipClicked,
Expand Down
Loading