1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 18:00:18 +01:00

Fixing warnings in unit test cases (#13349)

This commit is contained in:
Jyoti Puri 2022-01-20 00:04:22 +05:30 committed by GitHub
parent af848dec9b
commit 5b5b2cd7df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 50 additions and 40 deletions

View File

@ -1,4 +1,4 @@
import React from 'react'; import React, { useMemo } from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { import {
EDIT_GAS_MODES, EDIT_GAS_MODES,
@ -24,7 +24,7 @@ const EditGasToolTip = ({
transaction, transaction,
t, t,
}) => { }) => {
const toolTipMessage = () => { const toolTipMessage = useMemo(() => {
switch (priorityLevel) { switch (priorityLevel) {
case PRIORITY_LEVELS.LOW: case PRIORITY_LEVELS.LOW:
return t('lowGasSettingToolTipMessage', [ return t('lowGasSettingToolTipMessage', [
@ -76,7 +76,8 @@ const EditGasToolTip = ({
default: default:
return ''; return '';
} }
}; }, [editGasMode, estimateGreaterThanGasUse, priorityLevel, transaction, t]);
return ( return (
<div className="edit-gas-tooltip__container"> <div className="edit-gas-tooltip__container">
{priorityLevel !== PRIORITY_LEVELS.CUSTOM && {priorityLevel !== PRIORITY_LEVELS.CUSTOM &&
@ -97,9 +98,11 @@ const EditGasToolTip = ({
</Typography> </Typography>
</div> </div>
) : null} ) : null}
<div className="edit-gas-tooltip__container__message"> {toolTipMessage && (
<Typography variant={TYPOGRAPHY.H7}>{toolTipMessage()}</Typography> <div className="edit-gas-tooltip__container__message">
</div> <Typography variant={TYPOGRAPHY.H7}>{toolTipMessage}</Typography>
</div>
)}
{priorityLevel === PRIORITY_LEVELS.CUSTOM || {priorityLevel === PRIORITY_LEVELS.CUSTOM ||
estimateGreaterThanGasUse ? null : ( estimateGreaterThanGasUse ? null : (
<div className="edit-gas-tooltip__container__values"> <div className="edit-gas-tooltip__container__values">
@ -111,13 +114,15 @@ const EditGasToolTip = ({
> >
{t('maxBaseFee')} {t('maxBaseFee')}
</Typography> </Typography>
<Typography {maxFeePerGas && (
variant={TYPOGRAPHY.H7} <Typography
color={COLORS.NEUTRAL_GREY} variant={TYPOGRAPHY.H7}
className="edit-gas-tooltip__container__value" color={COLORS.NEUTRAL_GREY}
> className="edit-gas-tooltip__container__value"
{maxFeePerGas} >
</Typography> {maxFeePerGas}
</Typography>
)}
</div> </div>
<div> <div>
<Typography <Typography
@ -127,13 +132,15 @@ const EditGasToolTip = ({
> >
{t('priorityFeeProperCase')} {t('priorityFeeProperCase')}
</Typography> </Typography>
<Typography {maxPriorityFeePerGas && (
variant={TYPOGRAPHY.H7} <Typography
color={COLORS.NEUTRAL_GREY} variant={TYPOGRAPHY.H7}
className="edit-gas-tooltip__container__value" color={COLORS.NEUTRAL_GREY}
> className="edit-gas-tooltip__container__value"
{maxPriorityFeePerGas} >
</Typography> {maxPriorityFeePerGas}
</Typography>
)}
</div> </div>
<div> <div>
<Typography <Typography
@ -143,13 +150,15 @@ const EditGasToolTip = ({
> >
{t('gasLimit')} {t('gasLimit')}
</Typography> </Typography>
<Typography {gasLimit && (
variant={TYPOGRAPHY.H7} <Typography
color={COLORS.NEUTRAL_GREY} variant={TYPOGRAPHY.H7}
className="edit-gas-tooltip__container__value" color={COLORS.NEUTRAL_GREY}
> className="edit-gas-tooltip__container__value"
{gasLimit} >
</Typography> {gasLimit}
</Typography>
)}
</div> </div>
</div> </div>
)} )}

View File

@ -1,4 +1,4 @@
import React from 'react'; import React, { useMemo } from 'react';
import { uniq } from 'lodash'; import { uniq } from 'lodash';
import { roundToDecimalPlacesRemovingExtraZeroes } from '../../../../../helpers/utils/util'; import { roundToDecimalPlacesRemovingExtraZeroes } from '../../../../../helpers/utils/util';
import { useGasFeeContext } from '../../../../../contexts/gasFee'; import { useGasFeeContext } from '../../../../../contexts/gasFee';
@ -8,7 +8,7 @@ import { PriorityFeeTooltip } from '../tooltips';
export default function LatestPriorityFeeField() { export default function LatestPriorityFeeField() {
const { gasFeeEstimates } = useGasFeeContext(); const { gasFeeEstimates } = useGasFeeContext();
const renderPriorityFeeRange = () => { const priorityFeeRange = useMemo(() => {
const { latestPriorityFeeRange } = gasFeeEstimates; const { latestPriorityFeeRange } = gasFeeEstimates;
if (latestPriorityFeeRange) { if (latestPriorityFeeRange) {
const formattedRange = uniq([ const formattedRange = uniq([
@ -18,12 +18,14 @@ export default function LatestPriorityFeeField() {
return `${formattedRange} GWEI`; return `${formattedRange} GWEI`;
} }
return null; return null;
}; }, [gasFeeEstimates]);
return ( return (
<div className="network-statistics__info__field latest-priority-fee-field"> <div className="network-statistics__info__field latest-priority-fee-field">
<span className="network-statistics__info__field-data"> <span className="network-statistics__info__field-data">
<PriorityFeeTooltip>{renderPriorityFeeRange()}</PriorityFeeTooltip> {priorityFeeRange && (
<PriorityFeeTooltip>{priorityFeeRange}</PriorityFeeTooltip>
)}
</span> </span>
<span className="network-statistics__info__field-label"> <span className="network-statistics__info__field-label">
<I18nValue messageKey="priorityFee" /> <I18nValue messageKey="priorityFee" />

View File

@ -30,13 +30,12 @@ const NetworkStatistics = () => {
<div className="network-statistics__info"> <div className="network-statistics__info">
<div className="network-statistics__info__field"> <div className="network-statistics__info__field">
<span className="network-statistics__info__field-data"> <span className="network-statistics__info__field-data">
<BaseFeeTooltip> {gasFeeEstimates?.estimatedBaseFee && (
{gasFeeEstimates?.estimatedBaseFee && <BaseFeeTooltip>{`${roundToDecimalPlacesRemovingExtraZeroes(
`${roundToDecimalPlacesRemovingExtraZeroes( gasFeeEstimates?.estimatedBaseFee,
gasFeeEstimates?.estimatedBaseFee, 0,
0, )} GWEI`}</BaseFeeTooltip>
)} GWEI`} )}
</BaseFeeTooltip>
</span> </span>
<span className="network-statistics__info__field-label"> <span className="network-statistics__info__field-label">
<I18nValue messageKey="baseFee" /> <I18nValue messageKey="baseFee" />

View File

@ -35,7 +35,7 @@ export default function FeeCard({
onQuotesClick, onQuotesClick,
chainId, chainId,
isBestQuote, isBestQuote,
supportsEIP1559V2, supportsEIP1559V2 = false,
}) { }) {
const t = useContext(I18nContext); const t = useContext(I18nContext);
@ -211,5 +211,5 @@ FeeCard.propTypes = {
numberOfQuotes: PropTypes.number.isRequired, numberOfQuotes: PropTypes.number.isRequired,
chainId: PropTypes.string.isRequired, chainId: PropTypes.string.isRequired,
isBestQuote: PropTypes.bool.isRequired, isBestQuote: PropTypes.bool.isRequired,
supportsEIP1559V2: PropTypes.bool.isRequired, supportsEIP1559V2: PropTypes.bool,
}; };