2023-02-01 06:54:41 +01:00
|
|
|
import React from 'react';
|
|
|
|
import configureMockStore from 'redux-mock-store';
|
|
|
|
import thunk from 'redux-thunk';
|
2023-06-07 08:43:28 +02:00
|
|
|
import { fireEvent } from '@testing-library/react';
|
2023-02-01 06:54:41 +01:00
|
|
|
|
|
|
|
import { renderWithProvider } from '../../../test/lib/render-helpers';
|
|
|
|
import { setBackgroundConnection } from '../../../test/jest';
|
|
|
|
import { INITIAL_SEND_STATE_FOR_EXISTING_DRAFT } from '../../../test/jest/mocks';
|
|
|
|
import { GasEstimateTypes } from '../../../shared/constants/gas';
|
2023-03-21 15:43:22 +01:00
|
|
|
import { KeyringType } from '../../../shared/constants/keyring';
|
2023-02-01 06:54:41 +01:00
|
|
|
import { CHAIN_IDS } from '../../../shared/constants/network';
|
2023-05-18 19:19:40 +02:00
|
|
|
import {
|
|
|
|
TransactionStatus,
|
|
|
|
TransactionType,
|
|
|
|
} from '../../../shared/constants/transaction';
|
2023-02-01 06:54:41 +01:00
|
|
|
import { domainInitialState } from '../../ducks/domains';
|
|
|
|
|
|
|
|
import ConfirmTransactionBase from './confirm-transaction-base.container';
|
|
|
|
|
|
|
|
const middleware = [thunk];
|
|
|
|
|
|
|
|
setBackgroundConnection({
|
|
|
|
getGasFeeTimeEstimate: jest.fn(),
|
|
|
|
getGasFeeEstimatesAndStartPolling: jest.fn(),
|
|
|
|
promisifiedBackground: jest.fn(),
|
|
|
|
tryReverseResolveAddress: jest.fn(),
|
|
|
|
getNextNonce: jest.fn(),
|
|
|
|
});
|
|
|
|
|
2023-05-18 19:19:40 +02:00
|
|
|
const mockNetworkId = '5';
|
|
|
|
|
|
|
|
const mockTxParamsFromAddress = '0x123456789';
|
|
|
|
|
|
|
|
const mockTxParamsToAddress = '0x85c1685cfceaa5c0bdb1609fc536e9a8387dd65e';
|
|
|
|
const mockTxParamsToAddressConcat = '0x85c...D65e';
|
|
|
|
|
|
|
|
const mockParsedTxDataToAddressWithout0x =
|
|
|
|
'e57e7847fd3661a9b7c86aaf1daea08d9da5750a';
|
|
|
|
const mockParsedTxDataToAddress = '0xe57...750A';
|
|
|
|
|
|
|
|
const mockPropsToAddress = '0x33m1685cfceaa5c0bdb1609fc536e9a8387dd567';
|
|
|
|
const mockPropsToAddressConcat = '0x33m...d567';
|
|
|
|
|
|
|
|
const mockTxParams = {
|
|
|
|
from: mockTxParamsFromAddress,
|
|
|
|
to: mockTxParamsToAddress,
|
|
|
|
value: '0x5af3107a4000',
|
|
|
|
gas: '0x5208',
|
|
|
|
maxFeePerGas: '0x59682f16',
|
|
|
|
maxPriorityFeePerGas: '0x59682f00',
|
|
|
|
type: '0x2',
|
|
|
|
data: `0xa22cb465000000000000000000000000${mockParsedTxDataToAddressWithout0x}0000000000000000000000000000000000000000000000000000000000000001`,
|
|
|
|
};
|
|
|
|
|
2023-02-01 06:54:41 +01:00
|
|
|
const baseStore = {
|
2023-04-17 16:34:26 +02:00
|
|
|
send: {
|
|
|
|
...INITIAL_SEND_STATE_FOR_EXISTING_DRAFT,
|
|
|
|
currentTransactionUUID: null,
|
|
|
|
draftTransactions: {},
|
|
|
|
},
|
2023-02-01 06:54:41 +01:00
|
|
|
DNS: domainInitialState,
|
|
|
|
gas: {
|
|
|
|
customData: { limit: null, price: null },
|
|
|
|
},
|
|
|
|
history: { mostRecentOverviewPage: '/' },
|
|
|
|
metamask: {
|
|
|
|
unapprovedTxs: {
|
|
|
|
1: {
|
|
|
|
id: 1,
|
2023-05-18 19:19:40 +02:00
|
|
|
metamaskNetworkId: mockNetworkId,
|
|
|
|
txParams: { ...mockTxParams },
|
2023-02-01 06:54:41 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
gasEstimateType: GasEstimateTypes.legacy,
|
|
|
|
gasFeeEstimates: {
|
|
|
|
low: '0',
|
|
|
|
medium: '1',
|
|
|
|
fast: '2',
|
|
|
|
},
|
2023-05-18 19:19:40 +02:00
|
|
|
selectedAddress: mockTxParamsFromAddress,
|
2023-02-01 06:54:41 +01:00
|
|
|
keyrings: [
|
|
|
|
{
|
2023-03-21 15:43:22 +01:00
|
|
|
type: KeyringType.hdKeyTree,
|
2023-02-01 06:54:41 +01:00
|
|
|
accounts: ['0x0'],
|
|
|
|
},
|
|
|
|
],
|
2023-05-18 19:19:40 +02:00
|
|
|
networkId: mockNetworkId,
|
2023-02-01 06:54:41 +01:00
|
|
|
networkDetails: {
|
|
|
|
EIPS: {},
|
|
|
|
},
|
|
|
|
tokens: [],
|
|
|
|
preferences: {
|
|
|
|
useNativeCurrencyAsPrimaryCurrency: false,
|
|
|
|
},
|
|
|
|
currentCurrency: 'USD',
|
2023-05-02 17:53:20 +02:00
|
|
|
providerConfig: {
|
2023-02-01 06:54:41 +01:00
|
|
|
chainId: CHAIN_IDS.GOERLI,
|
|
|
|
},
|
|
|
|
nativeCurrency: 'ETH',
|
|
|
|
featureFlags: {
|
|
|
|
sendHexData: false,
|
|
|
|
},
|
|
|
|
addressBook: {
|
|
|
|
[CHAIN_IDS.GOERLI]: [],
|
|
|
|
},
|
|
|
|
cachedBalances: {
|
|
|
|
[CHAIN_IDS.GOERLI]: {},
|
|
|
|
},
|
|
|
|
accounts: {
|
2023-05-18 19:19:40 +02:00
|
|
|
[mockTxParamsFromAddress]: {
|
|
|
|
balance: '0x0',
|
|
|
|
address: mockTxParamsFromAddress,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
identities: {
|
|
|
|
[mockTxParamsFromAddress]: { address: mockTxParamsFromAddress },
|
|
|
|
[mockTxParamsToAddress]: {
|
|
|
|
name: 'Test Address 1',
|
|
|
|
},
|
2023-02-01 06:54:41 +01:00
|
|
|
},
|
|
|
|
tokenAddress: '0x32e6c34cd57087abbd59b5a4aecc4cb495924356',
|
|
|
|
tokenList: {},
|
|
|
|
ensResolutionsByAddress: {},
|
|
|
|
snaps: {},
|
|
|
|
},
|
|
|
|
confirmTransaction: {
|
|
|
|
txData: {
|
|
|
|
id: 1,
|
2023-05-18 19:19:40 +02:00
|
|
|
metamaskNetworkId: mockNetworkId,
|
|
|
|
txParams: { ...mockTxParams },
|
2023-02-01 06:54:41 +01:00
|
|
|
time: 1675012496170,
|
2023-05-18 19:19:40 +02:00
|
|
|
status: TransactionStatus.unapproved,
|
2023-02-01 06:54:41 +01:00
|
|
|
originalGasEstimate: '0x5208',
|
|
|
|
userEditedGasLimit: false,
|
|
|
|
chainId: '0x5',
|
|
|
|
loadingDefaults: false,
|
|
|
|
dappSuggestedGasFees: null,
|
|
|
|
sendFlowHistory: [],
|
|
|
|
origin: 'metamask',
|
|
|
|
actionId: 1675012496153.2039,
|
|
|
|
type: 'simpleSend',
|
|
|
|
history: [],
|
|
|
|
userFeeLevel: 'medium',
|
|
|
|
defaultGasEstimates: {
|
|
|
|
estimateType: 'medium',
|
|
|
|
gas: '0x5208',
|
|
|
|
maxFeePerGas: '0x59682f16',
|
|
|
|
maxPriorityFeePerGas: '0x59682f00',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
tokenData: {},
|
|
|
|
tokenProps: {},
|
|
|
|
fiatTransactionAmount: '0.16',
|
|
|
|
fiatTransactionFee: '0',
|
|
|
|
fiatTransactionTotal: '0.16',
|
|
|
|
ethTransactionAmount: '0.0001',
|
|
|
|
ethTransactionFee: '0',
|
|
|
|
ethTransactionTotal: '0.0001',
|
|
|
|
hexTransactionAmount: '0x5af3107a4000',
|
|
|
|
hexTransactionFee: '0x0',
|
|
|
|
hexTransactionTotal: '0x5af3107a4000',
|
|
|
|
nonce: '',
|
|
|
|
},
|
|
|
|
appState: {
|
|
|
|
sendInputCurrencySwitched: false,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2023-05-18 19:19:40 +02:00
|
|
|
const mockedStore = jest.mocked(baseStore);
|
|
|
|
|
|
|
|
const mockedStoreWithConfirmTxParams = (_mockTxParams = mockTxParams) => {
|
|
|
|
mockedStore.metamask.unapprovedTxs[1].txParams = { ..._mockTxParams };
|
|
|
|
mockedStore.confirmTransaction.txData.txParams = { ..._mockTxParams };
|
|
|
|
};
|
|
|
|
|
|
|
|
const sendToRecipientSelector =
|
|
|
|
'.sender-to-recipient__party--recipient .sender-to-recipient__name';
|
|
|
|
|
2023-02-01 06:54:41 +01:00
|
|
|
describe('Confirm Transaction Base', () => {
|
|
|
|
it('should match snapshot', () => {
|
2023-04-26 02:13:38 +02:00
|
|
|
const store = configureMockStore(middleware)(baseStore);
|
2023-02-01 06:54:41 +01:00
|
|
|
const { container } = renderWithProvider(
|
|
|
|
<ConfirmTransactionBase actionKey="confirm" />,
|
|
|
|
store,
|
|
|
|
);
|
|
|
|
expect(container).toMatchSnapshot();
|
|
|
|
});
|
2023-04-26 02:13:38 +02:00
|
|
|
|
2023-05-18 19:19:40 +02:00
|
|
|
it('should not contain L1 L2 fee details for chains that are not optimism', () => {
|
2023-04-26 02:13:38 +02:00
|
|
|
const store = configureMockStore(middleware)(baseStore);
|
2023-05-18 19:19:40 +02:00
|
|
|
const { queryByText } = renderWithProvider(
|
2023-04-26 02:13:38 +02:00
|
|
|
<ConfirmTransactionBase actionKey="confirm" />,
|
|
|
|
store,
|
|
|
|
);
|
2023-05-18 19:19:40 +02:00
|
|
|
expect(queryByText('Layer 1 fees')).not.toBeInTheDocument();
|
|
|
|
expect(queryByText('Layer 2 gas fee')).not.toBeInTheDocument();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should contain L1 L2 fee details for optimism', () => {
|
|
|
|
mockedStore.metamask.providerConfig.chainId = CHAIN_IDS.OPTIMISM;
|
|
|
|
mockedStore.confirmTransaction.txData.chainId = CHAIN_IDS.OPTIMISM;
|
|
|
|
const store = configureMockStore(middleware)(mockedStore);
|
|
|
|
const { queryByText } = renderWithProvider(
|
|
|
|
<ConfirmTransactionBase actionKey="confirm" />,
|
|
|
|
store,
|
|
|
|
);
|
|
|
|
expect(queryByText('Layer 1 fees')).toBeInTheDocument();
|
|
|
|
expect(queryByText('Layer 2 gas fee')).toBeInTheDocument();
|
2023-04-26 02:13:38 +02:00
|
|
|
});
|
2023-05-16 17:44:08 +02:00
|
|
|
|
|
|
|
it('should render NoteToTrader when isNoteToTraderSupported is true', () => {
|
2023-05-18 19:19:40 +02:00
|
|
|
mockedStore.metamask.custodyAccountDetails = {
|
|
|
|
[mockTxParamsFromAddress]: {
|
|
|
|
address: mockTxParamsFromAddress,
|
2023-05-16 17:44:08 +02:00
|
|
|
details: 'details',
|
|
|
|
custodyType: 'testCustody - Saturn',
|
|
|
|
custodianName: 'saturn-dev',
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2023-05-18 19:19:40 +02:00
|
|
|
mockedStore.metamask.mmiConfiguration = {
|
2023-05-16 17:44:08 +02:00
|
|
|
custodians: [
|
|
|
|
{
|
|
|
|
name: 'saturn-dev',
|
|
|
|
displayName: 'Saturn Custody',
|
|
|
|
isNoteToTraderSupported: true,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
|
|
|
|
2023-05-18 19:19:40 +02:00
|
|
|
const store = configureMockStore(middleware)(mockedStore);
|
2023-05-16 17:44:08 +02:00
|
|
|
const { getByTestId } = renderWithProvider(
|
|
|
|
<ConfirmTransactionBase actionKey="confirm" />,
|
|
|
|
store,
|
|
|
|
);
|
2023-06-08 11:01:06 +02:00
|
|
|
|
2023-05-16 17:44:08 +02:00
|
|
|
expect(getByTestId('transaction-note')).toBeInTheDocument();
|
|
|
|
});
|
2023-05-18 19:19:40 +02:00
|
|
|
|
2023-06-08 11:01:06 +02:00
|
|
|
it('handleMainSubmit calls sendTransaction correctly', async () => {
|
2023-06-07 08:43:28 +02:00
|
|
|
const newMockedStore = {
|
|
|
|
...mockedStore,
|
|
|
|
appState: {
|
|
|
|
...mockedStore.appState,
|
|
|
|
gasLoadingAnimationIsShowing: false,
|
|
|
|
},
|
|
|
|
metamask: {
|
|
|
|
...mockedStore.metamask,
|
|
|
|
accounts: {
|
|
|
|
[mockTxParamsFromAddress]: {
|
|
|
|
balance: '0x1000000000000000000',
|
|
|
|
address: mockTxParamsFromAddress,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
gasEstimateType: GasEstimateTypes.feeMarket,
|
|
|
|
networkDetails: {
|
|
|
|
...mockedStore.metamask.networkDetails,
|
|
|
|
EIPS: {
|
|
|
|
1559: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
customGas: {
|
|
|
|
gasLimit: '0x5208',
|
|
|
|
gasPrice: '0x59682f00',
|
|
|
|
},
|
|
|
|
noGasPrice: false,
|
|
|
|
},
|
|
|
|
send: {
|
|
|
|
...mockedStore.send,
|
|
|
|
gas: {
|
|
|
|
...mockedStore.send.gas,
|
|
|
|
gasEstimateType: GasEstimateTypes.legacy,
|
|
|
|
gasFeeEstimates: {
|
|
|
|
low: '0',
|
|
|
|
medium: '1',
|
|
|
|
high: '2',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
hasSimulationError: false,
|
|
|
|
userAcknowledgedGasMissing: false,
|
|
|
|
submitting: false,
|
|
|
|
hardwareWalletRequiresConnection: false,
|
|
|
|
gasIsLoading: false,
|
|
|
|
gasFeeIsCustom: true,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
const store = configureMockStore(middleware)(newMockedStore);
|
|
|
|
const sendTransaction = jest.fn().mockResolvedValue();
|
|
|
|
|
|
|
|
const { getByTestId } = renderWithProvider(
|
|
|
|
<ConfirmTransactionBase
|
|
|
|
actionKey="confirm"
|
|
|
|
sendTransaction={sendTransaction}
|
|
|
|
toAddress={mockPropsToAddress}
|
|
|
|
toAccounts={[{ address: mockPropsToAddress }]}
|
|
|
|
/>,
|
|
|
|
store,
|
|
|
|
);
|
|
|
|
const confirmButton = getByTestId('page-container-footer-next');
|
|
|
|
fireEvent.click(confirmButton);
|
|
|
|
expect(sendTransaction).toHaveBeenCalled();
|
|
|
|
});
|
|
|
|
|
2023-06-08 11:01:06 +02:00
|
|
|
it('handleMMISubmit calls sendTransaction correctly and then showCustodianDeepLink', async () => {
|
|
|
|
const newMockedStore = {
|
|
|
|
...mockedStore,
|
|
|
|
appState: {
|
|
|
|
...mockedStore.appState,
|
|
|
|
gasLoadingAnimationIsShowing: false,
|
|
|
|
},
|
|
|
|
confirmTransaction: {
|
|
|
|
...mockedStore.confirmTransaction,
|
|
|
|
txData: {
|
|
|
|
...mockedStore.confirmTransaction.txData,
|
|
|
|
custodyStatus: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
metamask: {
|
|
|
|
...mockedStore.metamask,
|
|
|
|
accounts: {
|
|
|
|
[mockTxParamsFromAddress]: {
|
|
|
|
balance: '0x1000000000000000000',
|
|
|
|
address: mockTxParamsFromAddress,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
gasEstimateType: GasEstimateTypes.feeMarket,
|
|
|
|
networkDetails: {
|
|
|
|
...mockedStore.metamask.networkDetails,
|
|
|
|
EIPS: {
|
|
|
|
1559: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
customGas: {
|
|
|
|
gasLimit: '0x5208',
|
|
|
|
gasPrice: '0x59682f00',
|
|
|
|
},
|
|
|
|
noGasPrice: false,
|
|
|
|
},
|
|
|
|
send: {
|
|
|
|
...mockedStore.send,
|
|
|
|
gas: {
|
|
|
|
...mockedStore.send.gas,
|
|
|
|
gasEstimateType: GasEstimateTypes.legacy,
|
|
|
|
gasFeeEstimates: {
|
|
|
|
low: '0',
|
|
|
|
medium: '1',
|
|
|
|
high: '2',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
hasSimulationError: false,
|
|
|
|
userAcknowledgedGasMissing: false,
|
|
|
|
submitting: false,
|
|
|
|
hardwareWalletRequiresConnection: false,
|
|
|
|
gasIsLoading: false,
|
|
|
|
gasFeeIsCustom: true,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
const store = configureMockStore(middleware)(newMockedStore);
|
|
|
|
const sendTransaction = jest
|
|
|
|
.fn()
|
|
|
|
.mockResolvedValue(newMockedStore.confirmTransaction.txData);
|
|
|
|
const showCustodianDeepLink = jest.fn();
|
|
|
|
const setWaitForConfirmDeepLinkDialog = jest.fn();
|
|
|
|
|
|
|
|
const { getByTestId } = renderWithProvider(
|
|
|
|
<ConfirmTransactionBase
|
|
|
|
actionKey="confirm"
|
|
|
|
sendTransaction={sendTransaction}
|
|
|
|
showCustodianDeepLink={showCustodianDeepLink}
|
|
|
|
setWaitForConfirmDeepLinkDialog={setWaitForConfirmDeepLinkDialog}
|
|
|
|
toAddress={mockPropsToAddress}
|
|
|
|
toAccounts={[{ address: mockPropsToAddress }]}
|
|
|
|
isMainBetaFlask={false}
|
|
|
|
/>,
|
|
|
|
store,
|
|
|
|
);
|
|
|
|
const confirmButton = getByTestId('page-container-footer-next');
|
|
|
|
fireEvent.click(confirmButton);
|
|
|
|
expect(setWaitForConfirmDeepLinkDialog).toHaveBeenCalled();
|
|
|
|
await expect(sendTransaction).toHaveBeenCalled();
|
|
|
|
expect(showCustodianDeepLink).toHaveBeenCalled();
|
|
|
|
});
|
|
|
|
|
2023-05-18 19:19:40 +02:00
|
|
|
describe('when rendering the recipient value', () => {
|
|
|
|
describe(`when the transaction is a ${TransactionType.simpleSend} type`, () => {
|
|
|
|
it(`should use txParams.to address`, () => {
|
|
|
|
const store = configureMockStore(middleware)(mockedStore);
|
|
|
|
const { container } = renderWithProvider(
|
|
|
|
<ConfirmTransactionBase actionKey="confirm" />,
|
|
|
|
store,
|
|
|
|
);
|
|
|
|
|
|
|
|
const recipientElem = container.querySelector(sendToRecipientSelector);
|
|
|
|
expect(recipientElem).toHaveTextContent(mockTxParamsToAddressConcat);
|
|
|
|
});
|
|
|
|
|
|
|
|
it(`should use txParams.to address even if there is no amount sent`, () => {
|
|
|
|
mockedStoreWithConfirmTxParams({
|
|
|
|
...mockTxParams,
|
|
|
|
value: '0x0',
|
|
|
|
});
|
|
|
|
const store = configureMockStore(middleware)(mockedStore);
|
|
|
|
const { container } = renderWithProvider(
|
|
|
|
<ConfirmTransactionBase actionKey="confirm" />,
|
|
|
|
store,
|
|
|
|
);
|
|
|
|
|
|
|
|
const recipientElem = container.querySelector(sendToRecipientSelector);
|
|
|
|
expect(recipientElem).toHaveTextContent(mockTxParamsToAddressConcat);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
describe(`when the transaction is NOT a ${TransactionType.simpleSend} type`, () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
mockedStore.confirmTransaction.txData.type =
|
|
|
|
TransactionType.contractInteraction;
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when there is an amount being sent (it should be treated as a general contract intereaction rather than custom one)', () => {
|
|
|
|
it('should use txParams.to address (contract address)', () => {
|
|
|
|
mockedStoreWithConfirmTxParams({
|
|
|
|
...mockTxParams,
|
|
|
|
value: '0x45666',
|
|
|
|
});
|
|
|
|
const store = configureMockStore(middleware)(mockedStore);
|
|
|
|
const { container } = renderWithProvider(
|
|
|
|
<ConfirmTransactionBase actionKey="confirm" />,
|
|
|
|
store,
|
|
|
|
);
|
|
|
|
|
|
|
|
const recipientElem = container.querySelector(
|
|
|
|
sendToRecipientSelector,
|
|
|
|
);
|
|
|
|
expect(recipientElem).toHaveTextContent(mockTxParamsToAddressConcat);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe(`when there is no amount being sent`, () => {
|
|
|
|
it('should use propToAddress (toAddress passed as prop)', () => {
|
|
|
|
mockedStoreWithConfirmTxParams({
|
|
|
|
...mockTxParams,
|
|
|
|
value: '0x0',
|
|
|
|
});
|
|
|
|
const store = configureMockStore(middleware)(mockedStore);
|
|
|
|
|
|
|
|
const { container } = renderWithProvider(
|
|
|
|
<ConfirmTransactionBase
|
|
|
|
// we want to test toAddress provided by ownProps in mapStateToProps, but this
|
|
|
|
// currently overrides toAddress this should pan out fine when we refactor the
|
|
|
|
// component into a functional component and remove the container.js file
|
|
|
|
toAddress={mockPropsToAddress}
|
|
|
|
actionKey="confirm"
|
|
|
|
/>,
|
|
|
|
store,
|
|
|
|
);
|
|
|
|
|
|
|
|
const recipientElem = container.querySelector(
|
|
|
|
sendToRecipientSelector,
|
|
|
|
);
|
|
|
|
expect(recipientElem).toHaveTextContent(mockPropsToAddressConcat);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should use address parsed from transaction data if propToAddress is not provided', () => {
|
|
|
|
mockedStoreWithConfirmTxParams({
|
|
|
|
...mockTxParams,
|
|
|
|
value: '0x0',
|
|
|
|
});
|
|
|
|
const store = configureMockStore(middleware)(mockedStore);
|
|
|
|
const { container } = renderWithProvider(
|
|
|
|
<ConfirmTransactionBase actionKey="confirm" />,
|
|
|
|
store,
|
|
|
|
);
|
|
|
|
|
|
|
|
const recipientElem = container.querySelector(
|
|
|
|
sendToRecipientSelector,
|
|
|
|
);
|
|
|
|
expect(recipientElem).toHaveTextContent(mockParsedTxDataToAddress);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should use txParams.to if neither propToAddress is not provided nor the transaction data to address were provided', () => {
|
|
|
|
mockedStoreWithConfirmTxParams({
|
|
|
|
...mockTxParams,
|
|
|
|
data: '0x',
|
|
|
|
value: '0x0',
|
|
|
|
});
|
|
|
|
const store = configureMockStore(middleware)(mockedStore);
|
|
|
|
const { container } = renderWithProvider(
|
|
|
|
<ConfirmTransactionBase actionKey="confirm" />,
|
|
|
|
store,
|
|
|
|
);
|
|
|
|
|
|
|
|
const recipientElem = container.querySelector(
|
|
|
|
sendToRecipientSelector,
|
|
|
|
);
|
|
|
|
expect(recipientElem).toHaveTextContent(mockTxParamsToAddressConcat);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2023-02-01 06:54:41 +01:00
|
|
|
});
|