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