2018-05-07 14:03:20 +02:00
|
|
|
import assert from 'assert'
|
2020-08-18 21:18:25 +02:00
|
|
|
import React from 'react'
|
2018-05-07 14:03:20 +02:00
|
|
|
import { shallow } from 'enzyme'
|
2020-08-14 13:46:45 +02:00
|
|
|
import SendContent from '../send-content.component'
|
2018-05-07 14:03:20 +02:00
|
|
|
|
2019-04-17 21:15:13 +02:00
|
|
|
import PageContainerContent from '../../../../components/ui/page-container/page-container-content.component'
|
2018-05-07 14:03:20 +02:00
|
|
|
import SendAmountRow from '../send-amount-row/send-amount-row.container'
|
|
|
|
import SendGasRow from '../send-gas-row/send-gas-row.container'
|
2018-08-16 09:43:13 +02:00
|
|
|
import SendHexDataRow from '../send-hex-data-row/send-hex-data-row.container'
|
2019-04-17 21:15:13 +02:00
|
|
|
import SendAssetRow from '../send-asset-row/send-asset-row.container'
|
2019-07-31 21:56:44 +02:00
|
|
|
import Dialog from '../../../../components/ui/dialog'
|
2018-05-07 14:03:20 +02:00
|
|
|
|
2018-05-10 13:37:33 +02:00
|
|
|
describe('SendContent Component', function () {
|
2018-05-07 14:03:20 +02:00
|
|
|
let wrapper
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
beforeEach(function () {
|
2019-07-31 21:56:44 +02:00
|
|
|
wrapper = shallow(
|
|
|
|
<SendContent
|
2019-11-19 00:23:41 +01:00
|
|
|
showHexData
|
2019-07-31 21:56:44 +02:00
|
|
|
/>,
|
2020-08-19 18:27:05 +02:00
|
|
|
{ context: { t: (str) => `${str}_t` } },
|
2019-07-31 21:56:44 +02:00
|
|
|
)
|
2018-05-07 14:03:20 +02:00
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('render', function () {
|
|
|
|
it('should render a PageContainerContent component', function () {
|
2018-05-07 14:03:20 +02:00
|
|
|
assert.equal(wrapper.find(PageContainerContent).length, 1)
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('should render a div with a .send-v2__form class as a child of PageContainerContent', function () {
|
2018-05-07 14:03:20 +02:00
|
|
|
const PageContainerContentChild = wrapper.find(PageContainerContent).children()
|
|
|
|
PageContainerContentChild.is('div')
|
|
|
|
PageContainerContentChild.is('.send-v2__form')
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('should render the correct row components as grandchildren of the PageContainerContent component', function () {
|
2018-05-07 14:03:20 +02:00
|
|
|
const PageContainerContentChild = wrapper.find(PageContainerContent).children()
|
2019-07-31 21:56:44 +02:00
|
|
|
assert(PageContainerContentChild.childAt(0).is(Dialog), 'row[0] should be Dialog')
|
|
|
|
assert(PageContainerContentChild.childAt(1).is(SendAssetRow), 'row[1] should be SendAssetRow')
|
|
|
|
assert(PageContainerContentChild.childAt(2).is(SendAmountRow), 'row[2] should be SendAmountRow')
|
|
|
|
assert(PageContainerContentChild.childAt(3).is(SendGasRow), 'row[3] should be SendGasRow')
|
|
|
|
assert(PageContainerContentChild.childAt(4).is(SendHexDataRow), 'row[4] should be SendHexDataRow')
|
2018-08-16 09:43:13 +02:00
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('should not render the SendHexDataRow if props.showHexData is false', function () {
|
2018-08-16 09:43:13 +02:00
|
|
|
wrapper.setProps({ showHexData: false })
|
|
|
|
const PageContainerContentChild = wrapper.find(PageContainerContent).children()
|
2019-07-31 21:56:44 +02:00
|
|
|
assert(PageContainerContentChild.childAt(0).is(Dialog), 'row[0] should be Dialog')
|
|
|
|
assert(PageContainerContentChild.childAt(1).is(SendAssetRow), 'row[1] should be SendAssetRow')
|
|
|
|
assert(PageContainerContentChild.childAt(2).is(SendAmountRow), 'row[2] should be SendAmountRow')
|
|
|
|
assert(PageContainerContentChild.childAt(3).is(SendGasRow), 'row[3] should be SendGasRow')
|
|
|
|
assert.equal(PageContainerContentChild.childAt(4).exists(), false)
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('should not render the Dialog if contact has a name', function () {
|
2019-07-31 21:56:44 +02:00
|
|
|
wrapper.setProps({
|
|
|
|
showHexData: false,
|
2019-08-14 01:13:05 +02:00
|
|
|
contact: { name: 'testName' },
|
2019-07-31 21:56:44 +02:00
|
|
|
})
|
|
|
|
const PageContainerContentChild = wrapper.find(PageContainerContent).children()
|
|
|
|
assert(PageContainerContentChild.childAt(0).is(SendAssetRow), 'row[1] should be SendAssetRow')
|
|
|
|
assert(PageContainerContentChild.childAt(1).is(SendAmountRow), 'row[2] should be SendAmountRow')
|
|
|
|
assert(PageContainerContentChild.childAt(2).is(SendGasRow), 'row[3] should be SendGasRow')
|
|
|
|
assert.equal(PageContainerContentChild.childAt(3).exists(), false)
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('should not render the Dialog if it is an ownedAccount', function () {
|
2019-07-31 21:56:44 +02:00
|
|
|
wrapper.setProps({
|
|
|
|
showHexData: false,
|
2019-08-14 01:13:05 +02:00
|
|
|
isOwnedAccount: true,
|
2019-07-31 21:56:44 +02:00
|
|
|
})
|
|
|
|
const PageContainerContentChild = wrapper.find(PageContainerContent).children()
|
|
|
|
assert(PageContainerContentChild.childAt(0).is(SendAssetRow), 'row[1] should be SendAssetRow')
|
|
|
|
assert(PageContainerContentChild.childAt(1).is(SendAmountRow), 'row[2] should be SendAmountRow')
|
|
|
|
assert(PageContainerContentChild.childAt(2).is(SendGasRow), 'row[3] should be SendGasRow')
|
|
|
|
assert.equal(PageContainerContentChild.childAt(3).exists(), false)
|
2018-05-07 14:03:20 +02:00
|
|
|
})
|
|
|
|
})
|
2019-07-24 01:51:13 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('should not render the asset dropdown if token length is 0 ', function () {
|
2019-07-24 01:51:13 +02:00
|
|
|
wrapper.setProps({ tokens: [] })
|
|
|
|
const PageContainerContentChild = wrapper.find(PageContainerContent).children()
|
2019-07-31 21:56:44 +02:00
|
|
|
assert(PageContainerContentChild.childAt(1).is(SendAssetRow))
|
|
|
|
assert(PageContainerContentChild.childAt(1).find('send-v2__asset-dropdown__single-asset'), true)
|
2019-07-24 01:51:13 +02:00
|
|
|
})
|
2020-08-28 17:27:07 +02:00
|
|
|
|
|
|
|
it('should render warning', function () {
|
|
|
|
wrapper.setProps({
|
|
|
|
warning: 'watchout',
|
|
|
|
})
|
|
|
|
|
|
|
|
const dialog = wrapper.find(Dialog).at(0)
|
|
|
|
|
|
|
|
assert.equal(dialog.props().type, 'warning')
|
|
|
|
assert.equal(dialog.props().children, 'watchout_t')
|
|
|
|
assert.equal(dialog.length, 1)
|
|
|
|
})
|
2018-05-07 14:03:20 +02:00
|
|
|
})
|