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.
Tag:
Branch:
Tree:
e1f392a1de
develop
feature/default_network_editable
v10.22.3
${ noResults }
104 lines
3.2 KiB
104 lines
3.2 KiB
import React from 'react';
|
|||
import GasPriceButtonGroup from '../../gas-price-button-group';
|
|||
import Loading from '../../../../ui/loading-screen';
|
|||
import { GAS_ESTIMATE_TYPES } from '../../../../../helpers/constants/common';
|
|||
|
import { shallowWithContext } from '../../../../../../test/lib/render-helpers';
|
||
import BasicTabContent from './basic-tab-content.component';
|
|||
|
|||
const mockGasPriceButtonGroupProps = {
|
|||
buttonDataLoading: false,
|
|||
className: 'gas-price-button-group',
|
|||
gasButtonInfo: [
|
|||
{
|
|||
feeInPrimaryCurrency: '$0.52',
|
|||
feeInSecondaryCurrency: '0.0048 ETH',
|
|||
timeEstimate: '~ 1 min 0 sec',
|
|||
priceInHexWei: '0xa1b2c3f',
|
|||
gasEstimateType: GAS_ESTIMATE_TYPES.AVERAGE,
|
|||
},
|
|||
{
|
|||
feeInPrimaryCurrency: '$0.39',
|
|||
feeInSecondaryCurrency: '0.004 ETH',
|
|||
timeEstimate: '~ 1 min 30 sec',
|
|||
priceInHexWei: '0xa1b2c39',
|
|||
gasEstimateType: GAS_ESTIMATE_TYPES.AVERAGE,
|
|||
},
|
|||
{
|
|||
feeInPrimaryCurrency: '$0.30',
|
|||
feeInSecondaryCurrency: '0.00354 ETH',
|
|||
timeEstimate: '~ 2 min 1 sec',
|
|||
priceInHexWei: '0xa1b2c30',
|
|||
gasEstimateType: GAS_ESTIMATE_TYPES.AVERAGE,
|
|||
},
|
|||
],
|
|||
|
handleGasPriceSelection: ({ gasPrice }) =>
|
||
console.log('NewPrice: ', gasPrice),
|
|||
noButtonActiveByDefault: true,
|
|||
showCheck: true,
|
|||
};
|
|||
|
|||
describe('BasicTabContent Component', () => {
|
|||
describe('render', () => {
|
|||
let wrapper;
|
|||
|
|||
beforeEach(() => {
|
|||
|
wrapper = shallowWithContext(
|
||
<BasicTabContent
|
|||
gasPriceButtonGroupProps={mockGasPriceButtonGroupProps}
|
|||
|
/>,
|
||
);
|
|||
});
|
|||
|
|||
it('should have a title', () => {
|
|||
expect(
|
|||
|
wrapper
|
||
.find('.basic-tab-content')
|
|||
.childAt(0)
|
|||
.hasClass('basic-tab-content__title'),
|
|||
).toStrictEqual(true);
|
|||
});
|
|||
|
|||
it('should render a GasPriceButtonGroup compenent', () => {
|
|||
expect(wrapper.find(GasPriceButtonGroup)).toHaveLength(1);
|
|||
});
|
|||
|
|||
it('should pass correct props to GasPriceButtonGroup', () => {
|
|||
const {
|
|||
buttonDataLoading,
|
|||
className,
|
|||
gasButtonInfo,
|
|||
handleGasPriceSelection,
|
|||
noButtonActiveByDefault,
|
|||
showCheck,
|
|||
} = wrapper.find(GasPriceButtonGroup).props();
|
|||
expect(wrapper.find(GasPriceButtonGroup)).toHaveLength(1);
|
|||
expect(buttonDataLoading).toStrictEqual(
|
|||
|
mockGasPriceButtonGroupProps.buttonDataLoading,
|
||
);
|
|||
expect(className).toStrictEqual(mockGasPriceButtonGroupProps.className);
|
|||
expect(noButtonActiveByDefault).toStrictEqual(
|
|||
|
mockGasPriceButtonGroupProps.noButtonActiveByDefault,
|
||
);
|
|||
expect(showCheck).toStrictEqual(mockGasPriceButtonGroupProps.showCheck);
|
|||
expect(gasButtonInfo).toStrictEqual(
|
|||
|
mockGasPriceButtonGroupProps.gasButtonInfo,
|
||
);
|
|||
expect(handleGasPriceSelection).toStrictEqual(
|
|||
mockGasPriceButtonGroupProps.handleGasPriceSelection,
|
|||
);
|
|||
});
|
|||
|
|||
it('should render a loading component instead of the GasPriceButtonGroup if gasPriceButtonGroupProps.loading is true', () => {
|
|||
wrapper.setProps({
|
|||
|
gasPriceButtonGroupProps: {
|
||
...mockGasPriceButtonGroupProps,
|
|||
loading: true,
|
|||
},
|
|||
});
|
|||
|
|||
expect(wrapper.find(GasPriceButtonGroup)).toHaveLength(0);
|
|||
expect(wrapper.find(Loading)).toHaveLength(1);
|
|||
});
|
|||
});
|
|||
});
|