@@ -2,14 +2,18 @@ import React from 'react';
22import { fireEvent , render } from '@testing-library/react-native' ;
33import { TextColor as DSTextColor } from '@metamask/design-system-react-native' ;
44import { CaipAssetType , CaipChainId , Hex } from '@metamask/utils' ;
5- import { formatAddressToAssetId } from '@metamask/bridge-controller' ;
5+ import {
6+ formatAddressToAssetId ,
7+ formatChainIdToCaip ,
8+ } from '@metamask/bridge-controller' ;
69import { BridgeToken } from '../../types' ;
710import { BatchSellTokenSelect } from './BatchSellTokenSelect' ;
811import { BatchSellTokenSelectSelectorsIDs } from './BatchSellTokenSelect.testIds' ;
912import {
1013 buildBatchSellEligibleChains ,
1114 removeStablecoinsFromSourceTokens ,
1215 MAX_BATCH_SELL_SOURCE_TOKENS ,
16+ SUPPORTED_BATCH_SELL_CHAIN_IDS ,
1317 sortBatchSellTokens ,
1418} from './BatchSellTokenSelect.utils' ;
1519import Routes from '../../../../../constants/navigation/Routes' ;
@@ -23,6 +27,7 @@ const mockDispatch = jest.fn();
2327const mockNavigate = jest . fn ( ) ;
2428const mockGoBack = jest . fn ( ) ;
2529const mockSetOptions = jest . fn ( ) ;
30+ const mockUseTokensWithBalance = jest . fn ( ) ;
2631let mockStablecoinsByChain : Record < CaipChainId , CaipAssetType [ ] > = { } ;
2732let mockWalletTokens : BridgeToken [ ] = [ ] ;
2833let mockPricePercentChangesByAddress : Record < string , number | undefined > = { } ;
@@ -307,7 +312,8 @@ jest.mock('../../../../../component-library/components/Buttons/Button', () => ({
307312} ) ) ;
308313
309314jest . mock ( '../../hooks/useTokensWithBalance' , ( ) => ( {
310- useTokensWithBalance : ( ) => mockWalletTokens ,
315+ useTokensWithBalance : ( options ?: { chainIds ?: CaipChainId [ ] } ) =>
316+ mockUseTokensWithBalance ( options ) ,
311317} ) ) ;
312318
313319jest . mock ( '../../../Tokens/hooks/useTokenPricePercentageChange' , ( ) => ( {
@@ -550,6 +556,19 @@ describe('BatchSellTokenSelect', () => {
550556 mockWalletTokens = [
551557 createToken ( { symbol : 'ETHA' , name : 'Ethereum A' , tokenFiatAmount : 10 } ) ,
552558 ] ;
559+ mockUseTokensWithBalance . mockImplementation (
560+ ( options ?: { chainIds ?: CaipChainId [ ] } ) => {
561+ if ( ! options ?. chainIds ) {
562+ return mockWalletTokens ;
563+ }
564+
565+ return mockWalletTokens . filter ( ( token ) =>
566+ options . chainIds ?. includes (
567+ formatChainIdToCaip ( token . chainId ) as CaipChainId ,
568+ ) ,
569+ ) ;
570+ } ,
571+ ) ;
553572 } ) ;
554573
555574 it ( 'renders only eligible wallet tokens' , ( ) => {
@@ -613,6 +632,38 @@ describe('BatchSellTokenSelect', () => {
613632 ) . not . toBeOnTheScreen ( ) ;
614633 } ) ;
615634
635+ it ( 'does not render network pills for unsupported networks' , ( ) => {
636+ mockWalletTokens = [
637+ createToken ( {
638+ symbol : 'ETHA' ,
639+ name : 'Ethereum A' ,
640+ tokenFiatAmount : 10 ,
641+ } ) ,
642+ createToken ( {
643+ symbol : 'AVAXA' ,
644+ name : 'Avalanche A' ,
645+ address : '0x2222222222222222222222222222222222222222' ,
646+ chainId : '0xa86a' as Hex ,
647+ tokenFiatAmount : 100 ,
648+ } ) ,
649+ ] ;
650+
651+ const { getByTestId, queryByTestId, queryByText } = render (
652+ < BatchSellTokenSelect /> ,
653+ ) ;
654+
655+ expect ( mockUseTokensWithBalance ) . toHaveBeenCalledWith ( {
656+ chainIds : SUPPORTED_BATCH_SELL_CHAIN_IDS ,
657+ } ) ;
658+ expect (
659+ getByTestId ( getNetworkPillTestId ( 'eip155:1' as CaipChainId ) ) ,
660+ ) . toBeOnTheScreen ( ) ;
661+ expect (
662+ queryByTestId ( getNetworkPillTestId ( 'eip155:43114' as CaipChainId ) ) ,
663+ ) . not . toBeOnTheScreen ( ) ;
664+ expect ( queryByText ( 'AVAXA' ) ) . not . toBeOnTheScreen ( ) ;
665+ } ) ;
666+
616667 it ( 'filters tokens to the selected network pill' , ( ) => {
617668 mockWalletTokens = [
618669 createToken ( {
0 commit comments