2021-02-04 19:15:23 +01:00
|
|
|
import React from 'react';
|
|
|
|
import { shallow } from 'enzyme';
|
|
|
|
import sinon from 'sinon';
|
2021-03-16 22:00:08 +01:00
|
|
|
import UserPreferencedCurrencyDisplay from '../../../../../components/app/user-preferenced-currency-display';
|
|
|
|
import GasFeeDisplay from './gas-fee-display.component';
|
2018-06-21 08:43:48 +02:00
|
|
|
|
|
|
|
const propsMethodSpies = {
|
|
|
|
showCustomizeGasModal: sinon.spy(),
|
2018-11-05 18:01:46 +01:00
|
|
|
onReset: sinon.spy(),
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2018-06-21 08:43:48 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
describe('GasFeeDisplay Component', () => {
|
2021-02-04 19:15:23 +01:00
|
|
|
let wrapper;
|
2018-06-21 08:43:48 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
describe('render', () => {
|
|
|
|
beforeEach(() => {
|
2020-11-03 00:41:28 +01:00
|
|
|
wrapper = shallow(
|
2020-02-11 17:51:13 +01:00
|
|
|
<GasFeeDisplay
|
|
|
|
conversionRate={20}
|
|
|
|
gasTotal="mockGasTotal"
|
|
|
|
primaryCurrency="mockPrimaryCurrency"
|
|
|
|
convertedCurrency="mockConvertedCurrency"
|
|
|
|
showGasButtonGroup={propsMethodSpies.showCustomizeGasModal}
|
|
|
|
onReset={propsMethodSpies.onReset}
|
2020-11-03 00:41:28 +01:00
|
|
|
/>,
|
|
|
|
{ context: { t: (str) => `${str}_t` } },
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
});
|
2018-06-21 08:43:48 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
afterEach(() => {
|
2021-02-04 19:15:23 +01:00
|
|
|
propsMethodSpies.showCustomizeGasModal.resetHistory();
|
|
|
|
});
|
2018-06-21 08:43:48 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('should render a CurrencyDisplay component', () => {
|
|
|
|
expect(wrapper.find(UserPreferencedCurrencyDisplay)).toHaveLength(2);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2018-06-21 08:43:48 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('should render the CurrencyDisplay with the correct props', () => {
|
2020-11-03 00:41:28 +01:00
|
|
|
const { type, value } = wrapper
|
|
|
|
.find(UserPreferencedCurrencyDisplay)
|
|
|
|
.at(0)
|
2021-02-04 19:15:23 +01:00
|
|
|
.props();
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(type).toStrictEqual('PRIMARY');
|
|
|
|
expect(value).toStrictEqual('mockGasTotal');
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2018-06-21 08:43:48 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('should render the reset button with the correct props', () => {
|
2021-02-04 19:15:23 +01:00
|
|
|
const { onClick, className } = wrapper.find('button').props();
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(className).toStrictEqual('gas-fee-reset');
|
|
|
|
expect(propsMethodSpies.onReset.callCount).toStrictEqual(0);
|
2021-02-04 19:15:23 +01:00
|
|
|
onClick();
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(propsMethodSpies.onReset.callCount).toStrictEqual(1);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2018-09-20 06:16:43 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('should render the reset button with the correct text', () => {
|
|
|
|
expect(wrapper.find('button').text()).toStrictEqual('reset_t');
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|