You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
92 lines
2.7 KiB
92 lines
2.7 KiB
4 years ago
|
import React from 'react';
|
||
|
import sinon from 'sinon';
|
||
4 years ago
|
import { shallowWithContext } from '../../../../../../test/lib/render-helpers';
|
||
4 years ago
|
import AdvancedTabContent from './advanced-tab-content.component';
|
||
6 years ago
|
|
||
4 years ago
|
describe('AdvancedTabContent Component', () => {
|
||
4 years ago
|
let wrapper;
|
||
6 years ago
|
|
||
4 years ago
|
beforeEach(() => {
|
||
5 years ago
|
const propsMethodSpies = {
|
||
|
updateCustomGasPrice: sinon.spy(),
|
||
|
updateCustomGasLimit: sinon.spy(),
|
||
4 years ago
|
};
|
||
|
sinon.spy(AdvancedTabContent.prototype, 'renderDataSummary');
|
||
5 years ago
|
|
||
4 years ago
|
wrapper = shallowWithContext(
|
||
5 years ago
|
<AdvancedTabContent
|
||
|
updateCustomGasPrice={propsMethodSpies.updateCustomGasPrice}
|
||
|
updateCustomGasLimit={propsMethodSpies.updateCustomGasLimit}
|
||
|
customModalGasPriceInHex="11"
|
||
|
customModalGasLimitInHex="23456"
|
||
|
transactionFee="$0.25"
|
||
|
insufficientBalance={false}
|
||
|
customPriceIsSafe
|
||
|
isSpeedUp={false}
|
||
4 years ago
|
/>,
|
||
4 years ago
|
);
|
||
|
});
|
||
6 years ago
|
|
||
4 years ago
|
afterEach(() => {
|
||
4 years ago
|
sinon.restore();
|
||
|
});
|
||
6 years ago
|
|
||
4 years ago
|
describe('render()', () => {
|
||
|
it('should render the advanced-tab root node', () => {
|
||
|
expect(wrapper.hasClass('advanced-tab')).toStrictEqual(true);
|
||
4 years ago
|
});
|
||
6 years ago
|
|
||
4 years ago
|
it('should render the expected child of the advanced-tab div', () => {
|
||
4 years ago
|
const advancedTabChildren = wrapper.children();
|
||
4 years ago
|
expect(advancedTabChildren).toHaveLength(2);
|
||
6 years ago
|
|
||
4 years ago
|
expect(
|
||
4 years ago
|
advancedTabChildren
|
||
|
.at(0)
|
||
|
.hasClass('advanced-tab__transaction-data-summary'),
|
||
4 years ago
|
).toStrictEqual(true);
|
||
4 years ago
|
});
|
||
6 years ago
|
|
||
4 years ago
|
it('should call renderDataSummary with the expected params', () => {
|
||
4 years ago
|
const renderDataSummaryArgs = AdvancedTabContent.prototype.renderDataSummary.getCall(
|
||
|
0,
|
||
4 years ago
|
).args;
|
||
4 years ago
|
expect(renderDataSummaryArgs).toStrictEqual(['$0.25']);
|
||
4 years ago
|
});
|
||
|
});
|
||
6 years ago
|
|
||
4 years ago
|
describe('renderDataSummary()', () => {
|
||
4 years ago
|
let dataSummary;
|
||
6 years ago
|
|
||
4 years ago
|
beforeEach(() => {
|
||
4 years ago
|
dataSummary = shallowWithContext(
|
||
4 years ago
|
wrapper.instance().renderDataSummary('mockTotalFee'),
|
||
4 years ago
|
);
|
||
|
});
|
||
6 years ago
|
|
||
4 years ago
|
it('should render the transaction-data-summary root node', () => {
|
||
|
expect(
|
||
|
dataSummary.hasClass('advanced-tab__transaction-data-summary'),
|
||
|
).toStrictEqual(true);
|
||
4 years ago
|
});
|
||
6 years ago
|
|
||
4 years ago
|
it('should render titles of the data', () => {
|
||
4 years ago
|
const titlesNode = dataSummary.children().at(0);
|
||
4 years ago
|
expect(
|
||
4 years ago
|
titlesNode.hasClass('advanced-tab__transaction-data-summary__titles'),
|
||
4 years ago
|
).toStrictEqual(true);
|
||
|
expect(titlesNode.children().at(0).text()).toStrictEqual(
|
||
4 years ago
|
'newTransactionFee',
|
||
4 years ago
|
);
|
||
|
});
|
||
6 years ago
|
|
||
4 years ago
|
it('should render the data', () => {
|
||
4 years ago
|
const dataNode = dataSummary.children().at(1);
|
||
4 years ago
|
expect(
|
||
4 years ago
|
dataNode.hasClass('advanced-tab__transaction-data-summary__container'),
|
||
4 years ago
|
).toStrictEqual(true);
|
||
|
expect(dataNode.children().at(0).text()).toStrictEqual('mockTotalFee');
|
||
4 years ago
|
});
|
||
|
});
|
||
|
});
|