aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/pages/send/send-content/tests/send-content-component.test.js
diff options
context:
space:
mode:
Diffstat (limited to 'ui/app/pages/send/send-content/tests/send-content-component.test.js')
-rw-r--r--ui/app/pages/send/send-content/tests/send-content-component.test.js63
1 files changed, 46 insertions, 17 deletions
diff --git a/ui/app/pages/send/send-content/tests/send-content-component.test.js b/ui/app/pages/send/send-content/tests/send-content-component.test.js
index d172423ab..451d2ea53 100644
--- a/ui/app/pages/send/send-content/tests/send-content-component.test.js
+++ b/ui/app/pages/send/send-content/tests/send-content-component.test.js
@@ -5,17 +5,21 @@ import SendContent from '../send-content.component.js'
import PageContainerContent from '../../../../components/ui/page-container/page-container-content.component'
import SendAmountRow from '../send-amount-row/send-amount-row.container'
-import SendFromRow from '../send-from-row/send-from-row.container'
import SendGasRow from '../send-gas-row/send-gas-row.container'
-import SendToRow from '../send-to-row/send-to-row.container'
import SendHexDataRow from '../send-hex-data-row/send-hex-data-row.container'
import SendAssetRow from '../send-asset-row/send-asset-row.container'
+import Dialog from '../../../../components/ui/dialog'
describe('SendContent Component', function () {
let wrapper
beforeEach(() => {
- wrapper = shallow(<SendContent showHexData={true} />)
+ wrapper = shallow(
+ <SendContent
+ showHexData={true}
+ />,
+ { context: { t: str => str + '_t' } }
+ )
})
describe('render', () => {
@@ -31,30 +35,55 @@ describe('SendContent Component', function () {
it('should render the correct row components as grandchildren of the PageContainerContent component', () => {
const PageContainerContentChild = wrapper.find(PageContainerContent).children()
- assert(PageContainerContentChild.childAt(0).is(SendFromRow))
- assert(PageContainerContentChild.childAt(1).is(SendToRow))
- assert(PageContainerContentChild.childAt(2).is(SendAssetRow))
- assert(PageContainerContentChild.childAt(3).is(SendAmountRow))
- assert(PageContainerContentChild.childAt(4).is(SendGasRow))
- assert(PageContainerContentChild.childAt(5).is(SendHexDataRow))
+ 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')
})
it('should not render the SendHexDataRow if props.showHexData is false', () => {
wrapper.setProps({ showHexData: false })
const PageContainerContentChild = wrapper.find(PageContainerContent).children()
- assert(PageContainerContentChild.childAt(0).is(SendFromRow))
- assert(PageContainerContentChild.childAt(1).is(SendToRow))
- assert(PageContainerContentChild.childAt(2).is(SendAssetRow))
- assert(PageContainerContentChild.childAt(3).is(SendAmountRow))
- assert(PageContainerContentChild.childAt(4).is(SendGasRow))
- assert.equal(PageContainerContentChild.childAt(5).exists(), false)
+ 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)
+ })
+
+ it('should not render the Dialog if addressBook contains "to" address', () => {
+ wrapper.setProps({
+ showHexData: false,
+ to: '0x80F061544cC398520615B5d3e7A3BedD70cd4510',
+ addressBook: [{ address: '0x80F061544cC398520615B5d3e7A3BedD70cd4510', name: 'dinodan' }],
+ })
+ 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)
+ })
+
+ it('should not render the Dialog if ownedAccounts contains "to" address', () => {
+ wrapper.setProps({
+ showHexData: false,
+ to: '0x80F061544cC398520615B5d3e7A3BedD70cd4510',
+ addressBook: [],
+ ownedAccounts: [{ address: '0x80F061544cC398520615B5d3e7A3BedD70cd4510', name: 'dinodan' }],
+ })
+ 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)
})
})
it('should not render the asset dropdown if token length is 0 ', () => {
wrapper.setProps({ tokens: [] })
const PageContainerContentChild = wrapper.find(PageContainerContent).children()
- assert(PageContainerContentChild.childAt(2).is(SendAssetRow))
- assert(PageContainerContentChild.childAt(2).find('send-v2__asset-dropdown__single-asset'), true)
+ assert(PageContainerContentChild.childAt(1).is(SendAssetRow))
+ assert(PageContainerContentChild.childAt(1).find('send-v2__asset-dropdown__single-asset'), true)
})
})