2021-02-04 19:15:23 +01:00
|
|
|
import React from 'react';
|
2023-01-17 16:51:35 +01:00
|
|
|
import configureMockStore from 'redux-mock-store';
|
|
|
|
import thunk from 'redux-thunk';
|
2023-01-18 15:47:29 +01:00
|
|
|
import { TransactionStatus } from '../../../../shared/constants/transaction';
|
2021-06-08 17:25:48 +02:00
|
|
|
import { GAS_LIMITS } from '../../../../shared/constants/gas';
|
2023-01-17 16:51:35 +01:00
|
|
|
import { renderWithProvider } from '../../../../test/lib/render-helpers';
|
|
|
|
import mockState from '../../../../test/data/mock-state.json';
|
|
|
|
import TransactionListItemDetails from '.';
|
|
|
|
|
|
|
|
jest.mock('../../../store/actions.js', () => ({
|
|
|
|
tryReverseResolveAddress: () => jest.fn(),
|
|
|
|
getGasFeeEstimatesAndStartPolling: jest.fn().mockResolvedValue(),
|
|
|
|
addPollingTokenToAppState: jest.fn(),
|
|
|
|
}));
|
2018-08-31 21:36:36 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
describe('TransactionListItemDetails Component', () => {
|
2023-01-17 16:51:35 +01:00
|
|
|
const transaction = {
|
|
|
|
history: [],
|
|
|
|
id: 1,
|
2023-01-18 15:47:29 +01:00
|
|
|
status: TransactionStatus.confirmed,
|
2023-01-17 16:51:35 +01:00
|
|
|
txParams: {
|
|
|
|
from: '0x1',
|
|
|
|
gas: GAS_LIMITS.SIMPLE,
|
|
|
|
gasPrice: '0x3b9aca00',
|
|
|
|
nonce: '0xa4',
|
|
|
|
to: '0x2',
|
|
|
|
value: '0x2386f26fc10000',
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const transactionGroup = {
|
|
|
|
transactions: [transaction],
|
|
|
|
primaryTransaction: transaction,
|
|
|
|
initialTransaction: transaction,
|
|
|
|
nonce: '0xa4',
|
|
|
|
hasRetried: false,
|
|
|
|
hasCancelled: false,
|
|
|
|
};
|
|
|
|
|
|
|
|
const rpcPrefs = {
|
|
|
|
blockExplorerUrl: 'https://customblockexplorer.com/',
|
|
|
|
};
|
|
|
|
|
|
|
|
const blockExplorerLinkText = {
|
|
|
|
firstPart: 'addBlockExplorer',
|
|
|
|
secondPart: '',
|
|
|
|
};
|
|
|
|
|
|
|
|
const props = {
|
|
|
|
onClose: jest.fn(),
|
|
|
|
title: 'Test Transaction Details',
|
|
|
|
recipientAddress: '0xAddress',
|
|
|
|
senderAddress: '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc',
|
|
|
|
tryReverseResolveAddress: jest.fn(),
|
|
|
|
transactionGroup,
|
|
|
|
transactionStatus: () => <div></div>,
|
|
|
|
blockExplorerLinkText,
|
|
|
|
rpcPrefs,
|
|
|
|
};
|
|
|
|
|
|
|
|
it('should render title with title prop', () => {
|
|
|
|
const mockStore = configureMockStore([thunk])(mockState);
|
|
|
|
|
|
|
|
const { queryByText } = renderWithProvider(
|
|
|
|
<TransactionListItemDetails {...props} />,
|
|
|
|
mockStore,
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2023-01-17 16:51:35 +01:00
|
|
|
|
|
|
|
expect(queryByText(props.title)).toBeInTheDocument();
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2018-08-31 21:36:36 +02:00
|
|
|
|
2023-01-17 16:51:35 +01:00
|
|
|
describe('Retry button', () => {
|
|
|
|
it('should render retry button with showRetry prop', () => {
|
|
|
|
const retryProps = {
|
|
|
|
...props,
|
|
|
|
showRetry: true,
|
|
|
|
};
|
2018-08-31 21:36:36 +02:00
|
|
|
|
2023-01-17 16:51:35 +01:00
|
|
|
const mockStore = configureMockStore([thunk])(mockState);
|
2020-05-26 22:49:11 +02:00
|
|
|
|
2023-01-17 16:51:35 +01:00
|
|
|
const { queryByTestId } = renderWithProvider(
|
|
|
|
<TransactionListItemDetails {...retryProps} />,
|
|
|
|
mockStore,
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(queryByTestId('rety-button')).toBeInTheDocument();
|
|
|
|
});
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2019-07-30 02:42:29 +02:00
|
|
|
|
2023-01-17 16:51:35 +01:00
|
|
|
describe('Cancel button', () => {
|
|
|
|
it('should render cancel button with showCancel prop', () => {
|
|
|
|
const retryProps = {
|
|
|
|
...props,
|
|
|
|
showCancel: true,
|
|
|
|
};
|
|
|
|
|
|
|
|
const mockStore = configureMockStore([thunk])(mockState);
|
2019-07-30 02:42:29 +02:00
|
|
|
|
2023-01-17 16:51:35 +01:00
|
|
|
const { queryByTestId } = renderWithProvider(
|
|
|
|
<TransactionListItemDetails {...retryProps} />,
|
|
|
|
mockStore,
|
|
|
|
);
|
2020-05-26 22:49:11 +02:00
|
|
|
|
2023-01-17 16:51:35 +01:00
|
|
|
expect(queryByTestId('cancel-button')).toBeInTheDocument();
|
|
|
|
});
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2019-07-30 02:42:29 +02:00
|
|
|
|
2023-01-17 16:51:35 +01:00
|
|
|
describe('Speedup button', () => {
|
|
|
|
it('should render speedup button with showSpeedUp prop', () => {
|
|
|
|
const retryProps = {
|
|
|
|
...props,
|
|
|
|
showSpeedUp: true,
|
|
|
|
};
|
|
|
|
|
|
|
|
const mockStore = configureMockStore([thunk])(mockState);
|
2019-07-30 02:42:29 +02:00
|
|
|
|
2023-01-17 16:51:35 +01:00
|
|
|
const { queryByTestId } = renderWithProvider(
|
|
|
|
<TransactionListItemDetails {...retryProps} />,
|
|
|
|
mockStore,
|
|
|
|
);
|
2020-05-26 22:49:11 +02:00
|
|
|
|
2023-01-17 16:51:35 +01:00
|
|
|
expect(queryByTestId('speedup-button')).toBeInTheDocument();
|
|
|
|
});
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|