2021-02-04 19:15:23 +01:00
|
|
|
import assert from 'assert';
|
|
|
|
import React from 'react';
|
|
|
|
import { shallow } from 'enzyme';
|
|
|
|
import sinon from 'sinon';
|
|
|
|
import GasFeeDisplay from '../gas-fee-display.component';
|
|
|
|
import UserPreferencedCurrencyDisplay from '../../../../../../components/app/user-preferenced-currency-display';
|
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
|
|
|
|
2018-11-05 18:01:46 +01:00
|
|
|
describe('GasFeeDisplay Component', function () {
|
2021-02-04 19:15:23 +01:00
|
|
|
let wrapper;
|
2018-06-21 08:43:48 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('render', function () {
|
|
|
|
beforeEach(function () {
|
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
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
afterEach(function () {
|
2021-02-04 19:15:23 +01:00
|
|
|
propsMethodSpies.showCustomizeGasModal.resetHistory();
|
|
|
|
});
|
2018-06-21 08:43:48 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('should render a CurrencyDisplay component', function () {
|
2021-02-04 19:15:23 +01:00
|
|
|
assert.strictEqual(
|
|
|
|
wrapper.find(UserPreferencedCurrencyDisplay).length,
|
|
|
|
2,
|
|
|
|
);
|
|
|
|
});
|
2018-06-21 08:43:48 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('should render the CurrencyDisplay with the correct props', function () {
|
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();
|
|
|
|
assert.strictEqual(type, 'PRIMARY');
|
|
|
|
assert.strictEqual(value, 'mockGasTotal');
|
|
|
|
});
|
2018-06-21 08:43:48 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('should render the reset button with the correct props', function () {
|
2021-02-04 19:15:23 +01:00
|
|
|
const { onClick, className } = wrapper.find('button').props();
|
|
|
|
assert.strictEqual(className, 'gas-fee-reset');
|
|
|
|
assert.strictEqual(propsMethodSpies.onReset.callCount, 0);
|
|
|
|
onClick();
|
|
|
|
assert.strictEqual(propsMethodSpies.onReset.callCount, 1);
|
|
|
|
});
|
2018-09-20 06:16:43 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('should render the reset button with the correct text', function () {
|
2021-02-04 19:15:23 +01:00
|
|
|
assert.strictEqual(wrapper.find('button').text(), 'reset_t');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|