1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-02 14:15:06 +01:00
metamask-extension/ui/components/app/gas-customization/gas-modal-page-container/advanced-tab-content/advanced-tab-content-component.test.js

92 lines
2.7 KiB
JavaScript
Raw Normal View History

import React from 'react';
import sinon from 'sinon';
import { shallowWithContext } from '../../../../../../test/lib/render-helpers';
import AdvancedTabContent from './advanced-tab-content.component';
describe('AdvancedTabContent Component', () => {
let wrapper;
beforeEach(() => {
const propsMethodSpies = {
updateCustomGasPrice: sinon.spy(),
updateCustomGasLimit: sinon.spy(),
};
sinon.spy(AdvancedTabContent.prototype, 'renderDataSummary');
wrapper = shallowWithContext(
<AdvancedTabContent
updateCustomGasPrice={propsMethodSpies.updateCustomGasPrice}
updateCustomGasLimit={propsMethodSpies.updateCustomGasLimit}
customModalGasPriceInHex="11"
customModalGasLimitInHex="23456"
transactionFee="$0.25"
insufficientBalance={false}
customPriceIsSafe
isSpeedUp={false}
customPriceIsExcessive={false}
2020-11-03 00:41:28 +01:00
/>,
);
});
afterEach(() => {
sinon.restore();
});
describe('render()', () => {
it('should render the advanced-tab root node', () => {
expect(wrapper.hasClass('advanced-tab')).toStrictEqual(true);
});
it('should render the expected child of the advanced-tab div', () => {
const advancedTabChildren = wrapper.children();
expect(advancedTabChildren).toHaveLength(2);
expect(
2020-11-03 00:41:28 +01:00
advancedTabChildren
.at(0)
.hasClass('advanced-tab__transaction-data-summary'),
).toStrictEqual(true);
});
it('should call renderDataSummary with the expected params', () => {
2022-07-31 20:26:40 +02:00
const renderDataSummaryArgs =
AdvancedTabContent.prototype.renderDataSummary.getCall(0).args;
expect(renderDataSummaryArgs).toStrictEqual(['$0.25']);
});
});
describe('renderDataSummary()', () => {
let dataSummary;
beforeEach(() => {
dataSummary = shallowWithContext(
wrapper.instance().renderDataSummary('mockTotalFee'),
);
});
it('should render the transaction-data-summary root node', () => {
expect(
dataSummary.hasClass('advanced-tab__transaction-data-summary'),
).toStrictEqual(true);
});
it('should render titles of the data', () => {
const titlesNode = dataSummary.children().at(0);
expect(
2020-11-03 00:41:28 +01:00
titlesNode.hasClass('advanced-tab__transaction-data-summary__titles'),
).toStrictEqual(true);
expect(titlesNode.children().at(0).text()).toStrictEqual(
'newTransactionFee',
);
});
it('should render the data', () => {
const dataNode = dataSummary.children().at(1);
expect(
2020-11-03 00:41:28 +01:00
dataNode.hasClass('advanced-tab__transaction-data-summary__container'),
).toStrictEqual(true);
expect(dataNode.children().at(0).text()).toStrictEqual('mockTotalFee');
});
});
});