mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Dead Code Removal: GasFeeDisplay (#14098)
This commit is contained in:
parent
4c5e48c49a
commit
0e995b24d1
@ -825,17 +825,6 @@
|
||||
height: 0;
|
||||
}
|
||||
|
||||
&__gas-fee-display {
|
||||
width: 100%;
|
||||
position: relative;
|
||||
|
||||
.currency-display--message {
|
||||
padding: 8px 38px 8px 10px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
|
||||
&__sliders-icon-container {
|
||||
@include Paragraph;
|
||||
|
||||
|
@ -1,45 +0,0 @@
|
||||
import React, { Component } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import UserPreferencedCurrencyDisplay from '../../../../../components/app/user-preferenced-currency-display';
|
||||
import { PRIMARY, SECONDARY } from '../../../../../helpers/constants/common';
|
||||
|
||||
export default class GasFeeDisplay extends Component {
|
||||
static propTypes = {
|
||||
gasLoadingError: PropTypes.bool,
|
||||
gasTotal: PropTypes.string,
|
||||
onReset: PropTypes.func,
|
||||
};
|
||||
|
||||
static contextTypes = {
|
||||
t: PropTypes.func,
|
||||
};
|
||||
|
||||
render() {
|
||||
const { gasTotal, gasLoadingError, onReset } = this.props;
|
||||
|
||||
return (
|
||||
<div className="send-v2__gas-fee-display">
|
||||
{/* eslint-disable-next-line no-nested-ternary */}
|
||||
{gasTotal ? (
|
||||
<div className="currency-display">
|
||||
<UserPreferencedCurrencyDisplay value={gasTotal} type={PRIMARY} />
|
||||
<UserPreferencedCurrencyDisplay
|
||||
className="currency-display__converted-value"
|
||||
value={gasTotal}
|
||||
type={SECONDARY}
|
||||
/>
|
||||
</div>
|
||||
) : gasLoadingError ? (
|
||||
<div className="currency-display.currency-display--message">
|
||||
{this.context.t('setGasPrice')}
|
||||
</div>
|
||||
) : (
|
||||
<div className="currency-display">{this.context.t('loading')}</div>
|
||||
)}
|
||||
<button className="gas-fee-reset" onClick={onReset}>
|
||||
{this.context.t('reset')}
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import sinon from 'sinon';
|
||||
import UserPreferencedCurrencyDisplay from '../../../../../components/app/user-preferenced-currency-display';
|
||||
import GasFeeDisplay from './gas-fee-display.component';
|
||||
|
||||
const propsMethodSpies = {
|
||||
showCustomizeGasModal: sinon.spy(),
|
||||
onReset: sinon.spy(),
|
||||
};
|
||||
|
||||
describe('GasFeeDisplay Component', () => {
|
||||
let wrapper;
|
||||
|
||||
describe('render', () => {
|
||||
beforeEach(() => {
|
||||
wrapper = shallow(
|
||||
<GasFeeDisplay
|
||||
conversionRate={20}
|
||||
gasTotal="mockGasTotal"
|
||||
primaryCurrency="mockPrimaryCurrency"
|
||||
convertedCurrency="mockConvertedCurrency"
|
||||
showGasButtonGroup={propsMethodSpies.showCustomizeGasModal}
|
||||
onReset={propsMethodSpies.onReset}
|
||||
/>,
|
||||
{ context: { t: (str) => `${str}_t` } },
|
||||
);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
propsMethodSpies.showCustomizeGasModal.resetHistory();
|
||||
});
|
||||
|
||||
it('should render a CurrencyDisplay component', () => {
|
||||
expect(wrapper.find(UserPreferencedCurrencyDisplay)).toHaveLength(2);
|
||||
});
|
||||
|
||||
it('should render the CurrencyDisplay with the correct props', () => {
|
||||
const { type, value } = wrapper
|
||||
.find(UserPreferencedCurrencyDisplay)
|
||||
.at(0)
|
||||
.props();
|
||||
expect(type).toStrictEqual('PRIMARY');
|
||||
expect(value).toStrictEqual('mockGasTotal');
|
||||
});
|
||||
|
||||
it('should render the reset button with the correct props', () => {
|
||||
const { onClick, className } = wrapper.find('button').props();
|
||||
expect(className).toStrictEqual('gas-fee-reset');
|
||||
expect(propsMethodSpies.onReset.callCount).toStrictEqual(0);
|
||||
onClick();
|
||||
expect(propsMethodSpies.onReset.callCount).toStrictEqual(1);
|
||||
});
|
||||
|
||||
it('should render the reset button with the correct text', () => {
|
||||
expect(wrapper.find('button').text()).toStrictEqual('reset_t');
|
||||
});
|
||||
});
|
||||
});
|
@ -1,22 +0,0 @@
|
||||
import React from 'react';
|
||||
import GasFeeDisplay from './gas-fee-display.component';
|
||||
|
||||
export default {
|
||||
title: 'Pages/Send/SendContent/SendGasRow/GasFeeDisplay',
|
||||
id: __filename,
|
||||
argTypes: {
|
||||
gasTotal: { control: 'number' },
|
||||
gasLoadingError: { control: 'boolean' },
|
||||
onReset: { action: 'OnReset' },
|
||||
},
|
||||
};
|
||||
|
||||
export const DefaultStory = (args) => {
|
||||
return <GasFeeDisplay {...args} />;
|
||||
};
|
||||
|
||||
DefaultStory.storyName = 'Default';
|
||||
DefaultStory.args = {
|
||||
gasTotal: 10000000000,
|
||||
gasLoadingError: false,
|
||||
};
|
@ -1 +0,0 @@
|
||||
export { default } from './gas-fee-display.component';
|
Loading…
x
Reference in New Issue
Block a user