1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-26 12:29:06 +01:00

Fixes tx list item test formatting, importing, and useDispatch mocking. (#12123)

This commit is contained in:
Thomas Huang 2021-09-15 16:04:14 -07:00 committed by GitHub
parent 2a9fbffb6c
commit 2b1e05f086
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,7 +16,7 @@ import {
import { useGasFeeEstimates } from '../../../hooks/useGasFeeEstimates'; import { useGasFeeEstimates } from '../../../hooks/useGasFeeEstimates';
import { GAS_ESTIMATE_TYPES } from '../../../../shared/constants/gas'; import { GAS_ESTIMATE_TYPES } from '../../../../shared/constants/gas';
import TransactionListItem from './transaction-list-item.component'; import TransactionListItem from '.';
const FEE_MARKET_ESTIMATE_RETURN_VALUE = { const FEE_MARKET_ESTIMATE_RETURN_VALUE = {
gasEstimateType: GAS_ESTIMATE_TYPES.FEE_MARKET, gasEstimateType: GAS_ESTIMATE_TYPES.FEE_MARKET,
@ -50,7 +50,7 @@ jest.mock('react-redux', () => {
return { return {
...actual, ...actual,
useSelector: jest.fn(), useSelector: jest.fn(),
useDispatch: jest.fn(), useDispatch: () => jest.fn(),
}; };
}); });
@ -93,18 +93,18 @@ const generateUseSelectorRouter = (opts) => (selector) => {
}; };
describe('TransactionListItem', () => { describe('TransactionListItem', () => {
describe('when account has insufficient balance to cover gas', function () { describe('when account has insufficient balance to cover gas', () => {
beforeAll(function () { beforeAll(() => {
useGasFeeEstimates.mockImplementation( useGasFeeEstimates.mockImplementation(
() => FEE_MARKET_ESTIMATE_RETURN_VALUE, () => FEE_MARKET_ESTIMATE_RETURN_VALUE,
); );
}); });
afterAll(function () { afterAll(() => {
useGasFeeEstimates.restore(); useGasFeeEstimates.restore();
}); });
it(`should indicate account has insufficient funds to cover gas price for cancellation of pending transaction`, function () { it(`should indicate account has insufficient funds to cover gas price for cancellation of pending transaction`, () => {
useSelector.mockImplementation( useSelector.mockImplementation(
generateUseSelectorRouter({ generateUseSelectorRouter({
balance: '0x3', balance: '0x3',
@ -116,7 +116,7 @@ describe('TransactionListItem', () => {
expect(queryByTestId('not-enough-gas__tooltip')).toBeInTheDocument(); expect(queryByTestId('not-enough-gas__tooltip')).toBeInTheDocument();
}); });
it('should not disable "cancel" button when user has sufficient funds', function () { it('should not disable "cancel" button when user has sufficient funds', () => {
useSelector.mockImplementation( useSelector.mockImplementation(
generateUseSelectorRouter({ generateUseSelectorRouter({
balance: '2AA1EFB94E0000', balance: '2AA1EFB94E0000',
@ -128,7 +128,7 @@ describe('TransactionListItem', () => {
expect(queryByTestId('not-enough-gas__tooltip')).not.toBeInTheDocument(); expect(queryByTestId('not-enough-gas__tooltip')).not.toBeInTheDocument();
}); });
it(`should open the edit gas popover when cancel is clicked`, function () { it(`should open the edit gas popover when cancel is clicked`, () => {
useSelector.mockImplementation( useSelector.mockImplementation(
generateUseSelectorRouter({ generateUseSelectorRouter({
balance: '2AA1EFB94E0000', balance: '2AA1EFB94E0000',