From fa703173a0a5cdf61ff5109feff7eceacda90880 Mon Sep 17 00:00:00 2001 From: Daniel <80175477+dan437@users.noreply.github.com> Date: Fri, 30 Jul 2021 19:40:41 +0200 Subject: [PATCH] Fix Jest unit tests (#11687) * Fix Jest unit tests * Provider correct getGasFeeTimeEstimate call to Gas Timing * Fix tests for correct getGasFeeTimeEstimate method name * Rename instances to getGasFeeTimeEstimate Co-authored-by: David Walsh Co-authored-by: Dan Miller --- ui/components/app/gas-timing/gas-timing.component.js | 4 ++-- ui/pages/swaps/fee-card/fee-card.test.js | 5 +++++ ui/pages/swaps/view-quote/view-quote.test.js | 1 + ui/store/actions.js | 4 ++-- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ui/components/app/gas-timing/gas-timing.component.js b/ui/components/app/gas-timing/gas-timing.component.js index 8c05c34d3..24ad349dc 100644 --- a/ui/components/app/gas-timing/gas-timing.component.js +++ b/ui/components/app/gas-timing/gas-timing.component.js @@ -15,7 +15,7 @@ import { } from '../../../helpers/constants/design-system'; import InfoTooltip from '../../ui/info-tooltip/info-tooltip'; -import { getGasTimeEstimate } from '../../../store/actions'; +import { getGasFeeTimeEstimate } from '../../../store/actions'; // Once we reach this second threshold, we switch to minutes as a unit const SECOND_CUTOFF = 90; @@ -61,7 +61,7 @@ export default function GasTiming({ priority !== previousMaxPriorityFeePerGas || fee !== previousMaxFeePerGas ) { - getGasTimeEstimate(priority, fee).then((result) => { + getGasFeeTimeEstimate(priority, fee).then((result) => { if (maxFeePerGas === fee && maxPriorityFeePerGas === priority) { setCustomEstimatedTime(result); } diff --git a/ui/pages/swaps/fee-card/fee-card.test.js b/ui/pages/swaps/fee-card/fee-card.test.js index 9185a6fea..c57f24f7a 100644 --- a/ui/pages/swaps/fee-card/fee-card.test.js +++ b/ui/pages/swaps/fee-card/fee-card.test.js @@ -5,6 +5,7 @@ import thunk from 'redux-thunk'; import { renderWithProvider, createSwapsMockStore, + setBackgroundConnection, MOCKS, } from '../../../../test/jest'; import { MAINNET_CHAIN_ID } from '../../../../shared/constants/network'; @@ -25,6 +26,10 @@ jest.mock('../../../hooks/useGasFeeEstimates', () => { }; }); +setBackgroundConnection({ + getGasFeeTimeEstimate: jest.fn(), +}); + const createProps = (customProps = {}) => { return { primaryFee: { diff --git a/ui/pages/swaps/view-quote/view-quote.test.js b/ui/pages/swaps/view-quote/view-quote.test.js index 89b802169..3698dec51 100644 --- a/ui/pages/swaps/view-quote/view-quote.test.js +++ b/ui/pages/swaps/view-quote/view-quote.test.js @@ -46,6 +46,7 @@ setBackgroundConnection({ setSwapsErrorKey: jest.fn(), getGasFeeEstimatesAndStartPolling: jest.fn(), updateTransaction: jest.fn(), + getGasFeeTimeEstimate: jest.fn(), }); describe('ViewQuote', () => { diff --git a/ui/store/actions.js b/ui/store/actions.js index 2a7b33bfd..1bc49d75b 100644 --- a/ui/store/actions.js +++ b/ui/store/actions.js @@ -2791,8 +2791,8 @@ export function disconnectGasFeeEstimatePoller(pollToken) { return promisifiedBackground.disconnectGasFeeEstimatePoller(pollToken); } -export function getGasTimeEstimate(maxPriorityFeePerGas, maxFeePerGas) { - return promisifiedBackground.getGasTimeEstimate( +export function getGasFeeTimeEstimate(maxPriorityFeePerGas, maxFeePerGas) { + return promisifiedBackground.getGasFeeTimeEstimate( maxPriorityFeePerGas, maxFeePerGas, );