2021-02-04 19:15:23 +01:00
|
|
|
import React from 'react';
|
|
|
|
import sinon from 'sinon';
|
2021-04-28 21:53:59 +02:00
|
|
|
import { shallowWithContext } from '../../../../../../test/lib/render-helpers';
|
2021-03-16 22:00:08 +01:00
|
|
|
import AdvancedTabContent from './advanced-tab-content.component';
|
2018-08-08 15:51:06 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
describe('AdvancedTabContent Component', () => {
|
2021-02-04 19:15:23 +01:00
|
|
|
let wrapper;
|
2018-08-08 15:51:06 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
beforeEach(() => {
|
2020-03-25 18:45:23 +01:00
|
|
|
const propsMethodSpies = {
|
|
|
|
updateCustomGasPrice: sinon.spy(),
|
|
|
|
updateCustomGasLimit: sinon.spy(),
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
|
|
|
sinon.spy(AdvancedTabContent.prototype, 'renderDataSummary');
|
2020-03-25 18:45:23 +01:00
|
|
|
|
2021-04-28 21:53:59 +02:00
|
|
|
wrapper = shallowWithContext(
|
2019-12-03 17:35:44 +01:00
|
|
|
<AdvancedTabContent
|
|
|
|
updateCustomGasPrice={propsMethodSpies.updateCustomGasPrice}
|
|
|
|
updateCustomGasLimit={propsMethodSpies.updateCustomGasLimit}
|
|
|
|
customModalGasPriceInHex="11"
|
|
|
|
customModalGasLimitInHex="23456"
|
|
|
|
transactionFee="$0.25"
|
|
|
|
insufficientBalance={false}
|
|
|
|
customPriceIsSafe
|
|
|
|
isSpeedUp={false}
|
2021-05-20 20:28:25 +02:00
|
|
|
customPriceIsExcessive={false}
|
2020-11-03 00:41:28 +01:00
|
|
|
/>,
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
});
|
2018-08-08 15:51:06 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
afterEach(() => {
|
2021-02-04 19:15:23 +01:00
|
|
|
sinon.restore();
|
|
|
|
});
|
2018-08-08 15:51:06 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
describe('render()', () => {
|
|
|
|
it('should render the advanced-tab root node', () => {
|
|
|
|
expect(wrapper.hasClass('advanced-tab')).toStrictEqual(true);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2018-08-08 15:51:06 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('should render the expected child of the advanced-tab div', () => {
|
2021-02-04 19:15:23 +01:00
|
|
|
const advancedTabChildren = wrapper.children();
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(advancedTabChildren).toHaveLength(2);
|
2018-08-08 15:51:06 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(
|
2020-11-03 00:41:28 +01:00
|
|
|
advancedTabChildren
|
|
|
|
.at(0)
|
|
|
|
.hasClass('advanced-tab__transaction-data-summary'),
|
2021-04-15 20:01:46 +02:00
|
|
|
).toStrictEqual(true);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2018-11-13 18:02:04 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('should call renderDataSummary with the expected params', () => {
|
2020-11-03 00:41:28 +01:00
|
|
|
const renderDataSummaryArgs = AdvancedTabContent.prototype.renderDataSummary.getCall(
|
|
|
|
0,
|
2021-02-04 19:15:23 +01:00
|
|
|
).args;
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(renderDataSummaryArgs).toStrictEqual(['$0.25']);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|
2018-08-08 15:51:06 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
describe('renderDataSummary()', () => {
|
2021-02-04 19:15:23 +01:00
|
|
|
let dataSummary;
|
2018-08-08 15:51:06 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
beforeEach(() => {
|
2021-04-28 21:53:59 +02:00
|
|
|
dataSummary = shallowWithContext(
|
2020-12-03 00:25:19 +01:00
|
|
|
wrapper.instance().renderDataSummary('mockTotalFee'),
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
});
|
2018-08-08 15:51:06 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('should render the transaction-data-summary root node', () => {
|
|
|
|
expect(
|
|
|
|
dataSummary.hasClass('advanced-tab__transaction-data-summary'),
|
|
|
|
).toStrictEqual(true);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2018-08-08 15:51:06 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('should render titles of the data', () => {
|
2021-02-04 19:15:23 +01:00
|
|
|
const titlesNode = dataSummary.children().at(0);
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(
|
2020-11-03 00:41:28 +01:00
|
|
|
titlesNode.hasClass('advanced-tab__transaction-data-summary__titles'),
|
2021-04-15 20:01:46 +02:00
|
|
|
).toStrictEqual(true);
|
|
|
|
expect(titlesNode.children().at(0).text()).toStrictEqual(
|
2020-12-03 16:46:22 +01:00
|
|
|
'newTransactionFee',
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
});
|
2018-08-08 15:51:06 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('should render the data', () => {
|
2021-02-04 19:15:23 +01:00
|
|
|
const dataNode = dataSummary.children().at(1);
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(
|
2020-11-03 00:41:28 +01:00
|
|
|
dataNode.hasClass('advanced-tab__transaction-data-summary__container'),
|
2021-04-15 20:01:46 +02:00
|
|
|
).toStrictEqual(true);
|
|
|
|
expect(dataNode.children().at(0).text()).toStrictEqual('mockTotalFee');
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|