Skip to content

Commit d1f40d6

Browse files
committed
Update test
1 parent a66bcca commit d1f40d6

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

app/components/Views/confirmations/components/send/recipient/recipient.test.tsx

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ import React from 'react';
22
import { fireEvent } from '@testing-library/react-native';
33

44
import renderWithProvider from '../../../../../../util/test/renderWithProvider';
5+
import { doENSLookup } from '../../../../../../util/ENSUtils';
56
import { useSendContext } from '../../../context/send-context/send-context';
67
import { useAccounts } from '../../../hooks/send/useAccounts';
78
import { useContacts } from '../../../hooks/send/useContacts';
89
import { useToAddressValidation } from '../../../hooks/send/useToAddressValidation';
910
import { useRecipientSelectionMetrics } from '../../../hooks/send/metrics/useRecipientSelectionMetrics';
1011
import { useSendActions } from '../../../hooks/send/useSendActions';
12+
import { useSendType } from '../../../hooks/send/useSendType';
1113
import { RecipientType } from '../../UI/recipient';
1214
import { 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+
6676
jest.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);
122133
const mockUseSendContext = jest.mocked(useSendContext);
123134
const mockUseAccounts = jest.mocked(useAccounts);
124135
const mockUseContacts = jest.mocked(useContacts);
@@ -127,6 +138,7 @@ const mockUseRecipientSelectionMetrics = jest.mocked(
127138
useRecipientSelectionMetrics,
128139
);
129140
const mockUseSendActions = jest.mocked(useSendActions);
141+
const mockUseSendType = jest.mocked(useSendType);
130142

131143
describe('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

app/components/Views/confirmations/components/send/recipient/recipient.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ export const Recipient = () => {
145145
/>
146146
)}
147147
<Button
148+
testID="review-button-send"
148149
variant={ButtonVariant.Primary}
149150
size={ButtonBaseSize.Lg}
150151
onPress={handleReview}

0 commit comments

Comments
 (0)