2021-02-04 19:15:23 +01:00
|
|
|
import React from 'react';
|
2021-03-16 22:00:08 +01:00
|
|
|
import GasPriceButtonGroup from '../../gas-price-button-group';
|
|
|
|
import Loading from '../../../../ui/loading-screen';
|
|
|
|
import { GAS_ESTIMATE_TYPES } from '../../../../../helpers/constants/common';
|
2021-04-28 21:53:59 +02:00
|
|
|
import { shallowWithContext } from '../../../../../../test/lib/render-helpers';
|
2021-03-16 22:00:08 +01:00
|
|
|
import BasicTabContent from './basic-tab-content.component';
|
2018-08-09 18:14:03 +02:00
|
|
|
|
|
|
|
const mockGasPriceButtonGroupProps = {
|
|
|
|
buttonDataLoading: false,
|
|
|
|
className: 'gas-price-button-group',
|
|
|
|
gasButtonInfo: [
|
|
|
|
{
|
|
|
|
feeInPrimaryCurrency: '$0.52',
|
|
|
|
feeInSecondaryCurrency: '0.0048 ETH',
|
|
|
|
timeEstimate: '~ 1 min 0 sec',
|
|
|
|
priceInHexWei: '0xa1b2c3f',
|
2020-01-16 22:49:01 +01:00
|
|
|
gasEstimateType: GAS_ESTIMATE_TYPES.AVERAGE,
|
2018-08-09 18:14:03 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
feeInPrimaryCurrency: '$0.39',
|
|
|
|
feeInSecondaryCurrency: '0.004 ETH',
|
|
|
|
timeEstimate: '~ 1 min 30 sec',
|
|
|
|
priceInHexWei: '0xa1b2c39',
|
2020-01-16 22:49:01 +01:00
|
|
|
gasEstimateType: GAS_ESTIMATE_TYPES.AVERAGE,
|
2018-08-09 18:14:03 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
feeInPrimaryCurrency: '$0.30',
|
|
|
|
feeInSecondaryCurrency: '0.00354 ETH',
|
|
|
|
timeEstimate: '~ 2 min 1 sec',
|
|
|
|
priceInHexWei: '0xa1b2c30',
|
2020-01-16 22:49:01 +01:00
|
|
|
gasEstimateType: GAS_ESTIMATE_TYPES.AVERAGE,
|
2018-08-09 18:14:03 +02:00
|
|
|
},
|
|
|
|
],
|
2020-11-13 01:41:01 +01:00
|
|
|
handleGasPriceSelection: ({ gasPrice }) =>
|
|
|
|
console.log('NewPrice: ', gasPrice),
|
2018-08-09 18:14:03 +02:00
|
|
|
noButtonActiveByDefault: true,
|
|
|
|
showCheck: true,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2018-08-09 18:14:03 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
describe('BasicTabContent Component', () => {
|
|
|
|
describe('render', () => {
|
2021-02-04 19:15:23 +01:00
|
|
|
let wrapper;
|
2018-08-09 18:14:03 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
beforeEach(() => {
|
2021-04-28 21:53:59 +02:00
|
|
|
wrapper = shallowWithContext(
|
2020-02-11 17:51:13 +01:00
|
|
|
<BasicTabContent
|
|
|
|
gasPriceButtonGroupProps={mockGasPriceButtonGroupProps}
|
2020-11-03 00:41:28 +01:00
|
|
|
/>,
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
});
|
2018-08-09 18:14:03 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('should have a title', () => {
|
|
|
|
expect(
|
2020-11-03 00:41:28 +01:00
|
|
|
wrapper
|
|
|
|
.find('.basic-tab-content')
|
|
|
|
.childAt(0)
|
|
|
|
.hasClass('basic-tab-content__title'),
|
2021-04-15 20:01:46 +02:00
|
|
|
).toStrictEqual(true);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2018-08-09 18:14:03 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('should render a GasPriceButtonGroup compenent', () => {
|
|
|
|
expect(wrapper.find(GasPriceButtonGroup)).toHaveLength(1);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2018-08-09 18:14:03 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('should pass correct props to GasPriceButtonGroup', () => {
|
2018-08-09 18:14:03 +02:00
|
|
|
const {
|
|
|
|
buttonDataLoading,
|
|
|
|
className,
|
|
|
|
gasButtonInfo,
|
|
|
|
handleGasPriceSelection,
|
|
|
|
noButtonActiveByDefault,
|
|
|
|
showCheck,
|
2021-02-04 19:15:23 +01:00
|
|
|
} = wrapper.find(GasPriceButtonGroup).props();
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(wrapper.find(GasPriceButtonGroup)).toHaveLength(1);
|
|
|
|
expect(buttonDataLoading).toStrictEqual(
|
2020-11-03 00:41:28 +01:00
|
|
|
mockGasPriceButtonGroupProps.buttonDataLoading,
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(className).toStrictEqual(mockGasPriceButtonGroupProps.className);
|
|
|
|
expect(noButtonActiveByDefault).toStrictEqual(
|
2020-11-03 00:41:28 +01:00
|
|
|
mockGasPriceButtonGroupProps.noButtonActiveByDefault,
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(showCheck).toStrictEqual(mockGasPriceButtonGroupProps.showCheck);
|
|
|
|
expect(gasButtonInfo).toStrictEqual(
|
2020-11-03 00:41:28 +01:00
|
|
|
mockGasPriceButtonGroupProps.gasButtonInfo,
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(handleGasPriceSelection).toStrictEqual(
|
|
|
|
mockGasPriceButtonGroupProps.handleGasPriceSelection,
|
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 render a loading component instead of the GasPriceButtonGroup if gasPriceButtonGroupProps.loading is true', () => {
|
2018-11-13 18:02:04 +01:00
|
|
|
wrapper.setProps({
|
2020-11-03 00:41:28 +01:00
|
|
|
gasPriceButtonGroupProps: {
|
|
|
|
...mockGasPriceButtonGroupProps,
|
|
|
|
loading: 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
|
|
|
expect(wrapper.find(GasPriceButtonGroup)).toHaveLength(0);
|
|
|
|
expect(wrapper.find(Loading)).toHaveLength(1);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|