From 2b1e05f086c4b1996b954b9762b5e52ec77fb8e0 Mon Sep 17 00:00:00 2001 From: Thomas Huang Date: Wed, 15 Sep 2021 16:04:14 -0700 Subject: [PATCH] Fixes tx list item test formatting, importing, and useDispatch mocking. (#12123) --- .../transaction-list-item.component.test.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ui/components/app/transaction-list-item/transaction-list-item.component.test.js b/ui/components/app/transaction-list-item/transaction-list-item.component.test.js index 048f3b346..de56d25ca 100644 --- a/ui/components/app/transaction-list-item/transaction-list-item.component.test.js +++ b/ui/components/app/transaction-list-item/transaction-list-item.component.test.js @@ -16,7 +16,7 @@ import { import { useGasFeeEstimates } from '../../../hooks/useGasFeeEstimates'; import { GAS_ESTIMATE_TYPES } from '../../../../shared/constants/gas'; -import TransactionListItem from './transaction-list-item.component'; +import TransactionListItem from '.'; const FEE_MARKET_ESTIMATE_RETURN_VALUE = { gasEstimateType: GAS_ESTIMATE_TYPES.FEE_MARKET, @@ -50,7 +50,7 @@ jest.mock('react-redux', () => { return { ...actual, useSelector: jest.fn(), - useDispatch: jest.fn(), + useDispatch: () => jest.fn(), }; }); @@ -93,18 +93,18 @@ const generateUseSelectorRouter = (opts) => (selector) => { }; describe('TransactionListItem', () => { - describe('when account has insufficient balance to cover gas', function () { - beforeAll(function () { + describe('when account has insufficient balance to cover gas', () => { + beforeAll(() => { useGasFeeEstimates.mockImplementation( () => FEE_MARKET_ESTIMATE_RETURN_VALUE, ); }); - afterAll(function () { + afterAll(() => { 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( generateUseSelectorRouter({ balance: '0x3', @@ -116,7 +116,7 @@ describe('TransactionListItem', () => { 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( generateUseSelectorRouter({ balance: '2AA1EFB94E0000', @@ -128,7 +128,7 @@ describe('TransactionListItem', () => { 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( generateUseSelectorRouter({ balance: '2AA1EFB94E0000',