2021-02-04 19:15:23 +01:00
|
|
|
import React from 'react';
|
|
|
|
import { shallow } from 'enzyme';
|
2021-03-16 22:00:08 +01:00
|
|
|
import PageContainerContent from '../../../components/ui/page-container/page-container-content.component';
|
|
|
|
import Dialog from '../../../components/ui/dialog';
|
|
|
|
import SendContent from './send-content.component';
|
2018-05-07 14:03:20 +02:00
|
|
|
|
2021-03-16 22:00:08 +01:00
|
|
|
import SendAmountRow from './send-amount-row/send-amount-row.container';
|
|
|
|
import SendHexDataRow from './send-hex-data-row/send-hex-data-row.container';
|
|
|
|
import SendAssetRow from './send-asset-row/send-asset-row.container';
|
2018-05-07 14:03:20 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
describe('SendContent Component', () => {
|
2021-02-04 19:15:23 +01:00
|
|
|
let wrapper;
|
2018-05-07 14:03:20 +02:00
|
|
|
|
2021-05-20 20:28:25 +02:00
|
|
|
const defaultProps = {
|
|
|
|
showHexData: true,
|
|
|
|
gasIsExcessive: false,
|
2021-08-03 00:52:18 +02:00
|
|
|
networkAndAccountSupports1559: true,
|
2021-11-03 20:03:54 +01:00
|
|
|
asset: { type: 'NATIVE' },
|
2022-07-14 00:15:38 +02:00
|
|
|
recipient: {
|
|
|
|
mode: 'CONTACT_LIST',
|
|
|
|
userInput: '0x31A2764925BD47CCBd57b2F277702dB46e9C5F66',
|
|
|
|
address: '0x31A2764925BD47CCBd57b2F277702dB46e9C5F66',
|
|
|
|
nickname: 'John Doe',
|
|
|
|
error: null,
|
|
|
|
warning: null,
|
|
|
|
},
|
|
|
|
tokenAddressList: {
|
|
|
|
'0x32e6c34cd57087abbd59b5a4aecc4cb495924356': {
|
|
|
|
name: 'BitBase',
|
|
|
|
symbol: 'BTBS',
|
|
|
|
decimals: 18,
|
|
|
|
address: '0x32E6C34Cd57087aBBD59B5A4AECC4cB495924356',
|
|
|
|
iconUrl: 'BTBS.svg',
|
|
|
|
occurrences: null,
|
|
|
|
},
|
|
|
|
'0x3fa400483487a489ec9b1db29c4129063eec4654': {
|
|
|
|
name: 'Cryptokek.com',
|
|
|
|
symbol: 'KEK',
|
|
|
|
decimals: 18,
|
|
|
|
address: '0x3fa400483487A489EC9b1dB29C4129063EEC4654',
|
|
|
|
iconUrl: 'cryptokek.svg',
|
|
|
|
occurrences: null,
|
|
|
|
},
|
|
|
|
},
|
2021-05-20 20:28:25 +02:00
|
|
|
};
|
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
beforeEach(() => {
|
2021-05-20 20:28:25 +02:00
|
|
|
wrapper = shallow(<SendContent {...defaultProps} />, {
|
2020-11-03 00:41:28 +01:00
|
|
|
context: { t: (str) => `${str}_t` },
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|
2018-05-07 14:03:20 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
describe('render', () => {
|
|
|
|
it('should render a PageContainerContent component', () => {
|
|
|
|
expect(wrapper.find(PageContainerContent)).toHaveLength(1);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2018-05-07 14:03:20 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('should render a div with a .send-v2__form class as a child of PageContainerContent', () => {
|
2020-11-03 00:41:28 +01:00
|
|
|
const PageContainerContentChild = wrapper
|
|
|
|
.find(PageContainerContent)
|
2021-02-04 19:15:23 +01:00
|
|
|
.children();
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(PageContainerContentChild.is('div')).toStrictEqual(true);
|
|
|
|
expect(PageContainerContentChild.is('.send-v2__form')).toStrictEqual(
|
|
|
|
true,
|
|
|
|
);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2018-05-07 14:03:20 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('should render the correct row components as grandchildren of the PageContainerContent component', () => {
|
2020-11-03 00:41:28 +01:00
|
|
|
const PageContainerContentChild = wrapper
|
|
|
|
.find(PageContainerContent)
|
2021-02-04 19:15:23 +01:00
|
|
|
.children();
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(PageContainerContentChild.childAt(0).is(Dialog)).toStrictEqual(
|
|
|
|
true,
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(
|
2020-11-03 00:41:28 +01:00
|
|
|
PageContainerContentChild.childAt(1).is(SendAssetRow),
|
2021-04-15 20:01:46 +02:00
|
|
|
).toStrictEqual(true);
|
|
|
|
expect(
|
2020-11-03 00:41:28 +01:00
|
|
|
PageContainerContentChild.childAt(2).is(SendAmountRow),
|
2021-04-15 20:01:46 +02:00
|
|
|
).toStrictEqual(true);
|
|
|
|
expect(
|
2021-07-31 03:29:21 +02:00
|
|
|
PageContainerContentChild.childAt(3).is(SendHexDataRow),
|
2021-04-15 20:01:46 +02:00
|
|
|
).toStrictEqual(true);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2018-08-16 09:43:13 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('should not render the SendHexDataRow if props.showHexData is false', () => {
|
2021-02-04 19:15:23 +01:00
|
|
|
wrapper.setProps({ showHexData: false });
|
2020-11-03 00:41:28 +01:00
|
|
|
const PageContainerContentChild = wrapper
|
|
|
|
.find(PageContainerContent)
|
2021-02-04 19:15:23 +01:00
|
|
|
.children();
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(PageContainerContentChild.childAt(0).is(Dialog)).toStrictEqual(
|
|
|
|
true,
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(
|
2020-11-03 00:41:28 +01:00
|
|
|
PageContainerContentChild.childAt(1).is(SendAssetRow),
|
2021-04-15 20:01:46 +02:00
|
|
|
).toStrictEqual(true);
|
|
|
|
expect(
|
2020-11-03 00:41:28 +01:00
|
|
|
PageContainerContentChild.childAt(2).is(SendAmountRow),
|
2021-04-15 20:01:46 +02:00
|
|
|
).toStrictEqual(true);
|
|
|
|
expect(wrapper.find(SendHexDataRow)).toHaveLength(0);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2019-07-31 21:56:44 +02:00
|
|
|
|
2021-11-03 20:03:54 +01:00
|
|
|
it('should not render the SendHexDataRow if the asset type is TOKEN (ERC-20)', () => {
|
|
|
|
wrapper.setProps({ asset: { type: 'TOKEN' } });
|
|
|
|
const PageContainerContentChild = wrapper
|
|
|
|
.find(PageContainerContent)
|
|
|
|
.children();
|
|
|
|
expect(PageContainerContentChild.childAt(0).is(Dialog)).toStrictEqual(
|
|
|
|
true,
|
|
|
|
);
|
|
|
|
expect(
|
|
|
|
PageContainerContentChild.childAt(1).is(SendAssetRow),
|
|
|
|
).toStrictEqual(true);
|
|
|
|
expect(
|
|
|
|
PageContainerContentChild.childAt(2).is(SendAmountRow),
|
|
|
|
).toStrictEqual(true);
|
|
|
|
expect(wrapper.find(SendHexDataRow)).toHaveLength(0);
|
|
|
|
});
|
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('should not render the Dialog if contact has a name', () => {
|
2019-07-31 21:56:44 +02:00
|
|
|
wrapper.setProps({
|
|
|
|
showHexData: false,
|
2019-08-14 01:13:05 +02:00
|
|
|
contact: { name: 'testName' },
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2020-11-03 00:41:28 +01:00
|
|
|
const PageContainerContentChild = wrapper
|
|
|
|
.find(PageContainerContent)
|
2021-02-04 19:15:23 +01:00
|
|
|
.children();
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(
|
2020-11-03 00:41:28 +01:00
|
|
|
PageContainerContentChild.childAt(0).is(SendAssetRow),
|
2021-04-15 20:01:46 +02:00
|
|
|
).toStrictEqual(true);
|
|
|
|
expect(
|
2020-11-03 00:41:28 +01:00
|
|
|
PageContainerContentChild.childAt(1).is(SendAmountRow),
|
2021-04-15 20:01:46 +02:00
|
|
|
).toStrictEqual(true);
|
|
|
|
expect(wrapper.find(Dialog)).toHaveLength(0);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2019-07-31 21:56:44 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('should not render the Dialog if it is an ownedAccount', () => {
|
2019-07-31 21:56:44 +02:00
|
|
|
wrapper.setProps({
|
|
|
|
showHexData: false,
|
2019-08-14 01:13:05 +02:00
|
|
|
isOwnedAccount: true,
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2020-11-03 00:41:28 +01:00
|
|
|
const PageContainerContentChild = wrapper
|
|
|
|
.find(PageContainerContent)
|
2021-02-04 19:15:23 +01:00
|
|
|
.children();
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(
|
2020-11-03 00:41:28 +01:00
|
|
|
PageContainerContentChild.childAt(0).is(SendAssetRow),
|
2021-04-15 20:01:46 +02:00
|
|
|
).toStrictEqual(true);
|
|
|
|
expect(
|
2020-11-03 00:41:28 +01:00
|
|
|
PageContainerContentChild.childAt(1).is(SendAmountRow),
|
2021-04-15 20:01:46 +02:00
|
|
|
).toStrictEqual(true);
|
|
|
|
expect(wrapper.find(Dialog)).toHaveLength(0);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|
2019-07-24 01:51:13 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('should not render the asset dropdown if token length is 0', () => {
|
2021-02-04 19:15:23 +01:00
|
|
|
wrapper.setProps({ tokens: [] });
|
2020-11-03 00:41:28 +01:00
|
|
|
const PageContainerContentChild = wrapper
|
|
|
|
.find(PageContainerContent)
|
2021-02-04 19:15:23 +01:00
|
|
|
.children();
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(PageContainerContentChild.childAt(1).is(SendAssetRow)).toStrictEqual(
|
|
|
|
true,
|
|
|
|
);
|
|
|
|
expect(
|
2022-07-14 00:15:38 +02:00
|
|
|
PageContainerContentChild.childAt(2).find(
|
2020-11-03 00:41:28 +01:00
|
|
|
'send-v2__asset-dropdown__single-asset',
|
|
|
|
),
|
2021-04-15 20:01:46 +02:00
|
|
|
).toHaveLength(0);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2020-08-28 17:27:07 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('should render warning', () => {
|
2020-08-28 17:27:07 +02:00
|
|
|
wrapper.setProps({
|
|
|
|
warning: 'watchout',
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2020-08-28 17:27:07 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
const dialog = wrapper.find(Dialog).at(0);
|
2020-08-28 17:27:07 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(dialog.props().type).toStrictEqual('warning');
|
|
|
|
expect(dialog.props().children).toStrictEqual('watchout_t');
|
|
|
|
expect(dialog).toHaveLength(1);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|