@@ -2,12 +2,14 @@ import React from 'react';
22import { fireEvent } from '@testing-library/react-native' ;
33
44import renderWithProvider from '../../../../../../util/test/renderWithProvider' ;
5+ import { doENSLookup } from '../../../../../../util/ENSUtils' ;
56import { useSendContext } from '../../../context/send-context/send-context' ;
67import { useAccounts } from '../../../hooks/send/useAccounts' ;
78import { useContacts } from '../../../hooks/send/useContacts' ;
89import { useToAddressValidation } from '../../../hooks/send/useToAddressValidation' ;
910import { useRecipientSelectionMetrics } from '../../../hooks/send/metrics/useRecipientSelectionMetrics' ;
1011import { useSendActions } from '../../../hooks/send/useSendActions' ;
12+ import { useSendType } from '../../../hooks/send/useSendType' ;
1113import { RecipientType } from '../../UI/recipient' ;
1214import { Recipient } from './recipient' ;
1315
@@ -63,6 +65,14 @@ jest.mock('./recipient.styles', () => ({
6365 } ) ) ,
6466} ) ) ;
6567
68+ jest . mock ( '../../../hooks/send/useSendType' , ( ) => ( {
69+ useSendType : jest . fn ( ) ,
70+ } ) ) ;
71+
72+ jest . mock ( '../../../../../../util/ENSUtils' , ( ) => ( {
73+ doENSLookup : jest . fn ( ) ,
74+ } ) ) ;
75+
6676jest . mock ( '../../recipient-list/recipient-list' , ( ) => ( {
6777 // eslint-disable-next-line @typescript-eslint/no-explicit-any
6878 RecipientList : ( { data, onRecipientSelected, emptyMessage } : any ) => {
@@ -119,6 +129,7 @@ jest.mock('../../../../../../../locales/i18n', () => ({
119129 } ) ,
120130} ) ) ;
121131
132+ const mockDoENSLookup = jest . mocked ( doENSLookup ) ;
122133const mockUseSendContext = jest . mocked ( useSendContext ) ;
123134const mockUseAccounts = jest . mocked ( useAccounts ) ;
124135const mockUseContacts = jest . mocked ( useContacts ) ;
@@ -127,6 +138,7 @@ const mockUseRecipientSelectionMetrics = jest.mocked(
127138 useRecipientSelectionMetrics ,
128139) ;
129140const mockUseSendActions = jest . mocked ( useSendActions ) ;
141+ const mockUseSendType = jest . mocked ( useSendType ) ;
130142
131143describe ( 'Recipient' , ( ) => {
132144 const mockUpdateTo = jest . fn ( ) ;
@@ -176,6 +188,15 @@ describe('Recipient', () => {
176188 handleCancelPress : jest . fn ( ) ,
177189 handleBackPress : jest . fn ( ) ,
178190 } ) ;
191+
192+ mockDoENSLookup . mockReturnValue ( Promise . resolve ( '' ) ) ;
193+ mockUseSendType . mockReturnValue ( {
194+ isEvmSendType : true ,
195+ isEvmNativeSendType : false ,
196+ isNonEvmSendType : false ,
197+ isNonEvmNativeSendType : false ,
198+ isSolanaSendType : false ,
199+ } ) ;
179200 } ) ;
180201
181202 it ( 'renders recipient input correctly' , ( ) => {
@@ -248,6 +269,32 @@ describe('Recipient', () => {
248269 expect ( mockCaptureRecipientSelected ) . toHaveBeenCalledTimes ( 1 ) ;
249270 } ) ;
250271
272+ it ( 'calls DNSResolver when address it is an EVMSendType on submission' , ( ) => {
273+ mockUseToAddressValidation . mockReturnValue ( {
274+ toAddressError : undefined ,
275+ toAddressWarning : undefined ,
276+ validateToAddress : jest . fn ( ) ,
277+ } ) ;
278+ mockUseSendContext . mockReturnValue ( {
279+ to : '0x1234567890123456789012345678901234567890' ,
280+ updateTo : mockUpdateTo ,
281+ asset : undefined ,
282+ chainId : undefined ,
283+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
284+ fromAccount : { } as any ,
285+ from : '' ,
286+ updateAsset : jest . fn ( ) ,
287+ updateValue : jest . fn ( ) ,
288+ value : undefined ,
289+ } ) ;
290+
291+ const { getByTestId } = renderWithProvider ( < Recipient /> ) ;
292+
293+ fireEvent . press ( getByTestId ( 'review-button-send' ) ) ;
294+
295+ expect ( mockDoENSLookup ) . toHaveBeenCalledTimes ( 1 ) ;
296+ } ) ;
297+
251298 it ( 'passes correct isRecipientSelectedFromList prop to RecipientInput initially' , ( ) => {
252299 const { getByText } = renderWithProvider ( < Recipient /> ) ;
253300
0 commit comments