1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Confirm transaction test (#17780)

This commit is contained in:
Jyoti Puri 2023-02-16 20:23:15 +05:30 committed by GitHub
parent 41e2c2beff
commit 9979020252
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 49 additions and 2 deletions

View File

@ -549,7 +549,7 @@ export function getSnapDerivationPathName(path, curve) {
/**
* The method escape RTL character in string
*
* @param {any} value
* @param {*} value
* @returns {(string|*)} escaped string or original param value
*/
export const sanitizeString = (value) => {

View File

@ -93,7 +93,7 @@ export default class ConfirmTransactionBase extends Component {
sendTransaction: PropTypes.func,
showTransactionConfirmedModal: PropTypes.func,
showRejectTransactionsConfirmationModal: PropTypes.func,
toAccounts: PropTypes.object,
toAccounts: PropTypes.array,
toAddress: PropTypes.string,
tokenData: PropTypes.object,
tokenProps: PropTypes.object,

View File

@ -0,0 +1,47 @@
import React from 'react';
import configureMockStore from 'redux-mock-store';
import thunk from 'redux-thunk';
import { renderWithProvider } from '../../../test/lib/render-helpers';
import { setBackgroundConnection } from '../../../test/jest';
import mockState from '../../../test/data/mock-state.json';
import {
CONFIRM_SEND_ETHER_PATH,
CONFIRM_TRANSACTION_ROUTE,
} from '../../helpers/constants/routes';
import ConfirmTransaction from './confirm-transaction.component';
const middleware = [thunk];
setBackgroundConnection({
getGasFeeTimeEstimate: jest.fn(),
getGasFeeEstimatesAndStartPolling: jest.fn(),
promisifiedBackground: jest.fn(),
tryReverseResolveAddress: jest.fn(),
getNextNonce: jest.fn(),
addKnownMethodData: jest.fn(),
});
describe('Confirm Transaction', () => {
const unapprovedTransactionId = Object.keys(
mockState.metamask.unapprovedTxs,
)[0];
it('should render correct information for approve transaction with value', () => {
const store = configureMockStore(middleware)({
...mockState,
confirmTransaction: {
txData: mockState.metamask.unapprovedTxs[unapprovedTransactionId],
},
});
const { getByText, getByRole } = renderWithProvider(
<ConfirmTransaction actionKey="confirm" />,
store,
`${CONFIRM_TRANSACTION_ROUTE}/${unapprovedTransactionId}${CONFIRM_SEND_ETHER_PATH}`,
);
expect(getByText('0xb19...0c5e')).toBeInTheDocument();
expect(getByRole('button', { name: 'Details' })).toBeInTheDocument();
expect(getByRole('button', { name: 'Data' })).toBeInTheDocument();
expect(getByRole('button', { name: 'Hex' })).toBeInTheDocument();
});
});