mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-04 23:14:56 +01:00
80 lines
2.3 KiB
JavaScript
80 lines
2.3 KiB
JavaScript
import React from 'react';
|
|
import { screen } from '@testing-library/react';
|
|
|
|
import { GAS_ESTIMATE_TYPES } from '../../../../shared/constants/gas';
|
|
import { TRANSACTION_ENVELOPE_TYPES } from '../../../../shared/constants/transaction';
|
|
|
|
import { GasFeeContextProvider } from '../../../contexts/gasFee';
|
|
import { renderWithProvider } from '../../../../test/jest';
|
|
import mockEstimates from '../../../../test/data/mock-estimates.json';
|
|
import mockState from '../../../../test/data/mock-state.json';
|
|
import configureStore from '../../../store/store';
|
|
|
|
import TransactionDetail from './transaction-detail.component';
|
|
|
|
jest.mock('../../../store/actions', () => ({
|
|
disconnectGasFeeEstimatePoller: jest.fn(),
|
|
getGasFeeEstimatesAndStartPolling: jest
|
|
.fn()
|
|
.mockImplementation(() => Promise.resolve()),
|
|
addPollingTokenToAppState: jest.fn(),
|
|
}));
|
|
|
|
const render = ({ componentProps, contextProps } = {}) => {
|
|
const store = configureStore({
|
|
metamask: {
|
|
...mockState.metamask,
|
|
accounts: {
|
|
[mockState.metamask.selectedAddress]: {
|
|
address: mockState.metamask.selectedAddress,
|
|
balance: '0x1F4',
|
|
},
|
|
},
|
|
gasFeeEstimates: mockEstimates[GAS_ESTIMATE_TYPES.FEE_MARKET],
|
|
},
|
|
});
|
|
|
|
return renderWithProvider(
|
|
<GasFeeContextProvider {...contextProps}>
|
|
<TransactionDetail
|
|
onEdit={() => {
|
|
console.log('on edit');
|
|
}}
|
|
rows={[]}
|
|
userAcknowledgedGasMissing
|
|
{...componentProps}
|
|
/>
|
|
</GasFeeContextProvider>,
|
|
store,
|
|
);
|
|
};
|
|
|
|
describe('TransactionDetail', () => {
|
|
beforeEach(() => {
|
|
process.env.EIP_1559_V2 = true;
|
|
});
|
|
|
|
afterEach(() => {
|
|
process.env.EIP_1559_V2 = false;
|
|
});
|
|
|
|
it('should render edit link with text low if low gas estimates are selected', () => {
|
|
render({ contextProps: { transaction: { userFeeLevel: 'low' } } });
|
|
expect(screen.queryByText('🐢')).toBeInTheDocument();
|
|
expect(screen.queryByText('Low')).toBeInTheDocument();
|
|
});
|
|
|
|
it('should render edit link with text edit for legacy transactions', () => {
|
|
render({
|
|
contextProps: {
|
|
transaction: {
|
|
userFeeLevel: 'low',
|
|
txParams: { type: TRANSACTION_ENVELOPE_TYPES.LEGACY },
|
|
},
|
|
},
|
|
});
|
|
expect(screen.queryByText('🐢')).not.toBeInTheDocument();
|
|
expect(screen.queryByText('Edit')).toBeInTheDocument();
|
|
});
|
|
});
|