aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components/send_/send-content/send-gas-row/tests/send-gas-row-component.test.js
diff options
context:
space:
mode:
authorDan <danjm.com@gmail.com>2018-05-11 00:17:05 +0800
committerDan <danjm.com@gmail.com>2018-05-11 00:17:05 +0800
commit22e2806ae22548c78f94c90e11597a823351d80f (patch)
treeadd1f16d94c8bcaa1b04bbe79f7168910966feeb /ui/app/components/send_/send-content/send-gas-row/tests/send-gas-row-component.test.js
parentf94ffa022c9f76a8d7acbf331f49a363d5e7362d (diff)
downloadtangerine-wallet-browser-22e2806ae22548c78f94c90e11597a823351d80f.tar.gz
tangerine-wallet-browser-22e2806ae22548c78f94c90e11597a823351d80f.tar.zst
tangerine-wallet-browser-22e2806ae22548c78f94c90e11597a823351d80f.zip
Unit tests for send from, gas, to and wrapper row components.
Diffstat (limited to 'ui/app/components/send_/send-content/send-gas-row/tests/send-gas-row-component.test.js')
-rw-r--r--ui/app/components/send_/send-content/send-gas-row/tests/send-gas-row-component.test.js69
1 files changed, 69 insertions, 0 deletions
diff --git a/ui/app/components/send_/send-content/send-gas-row/tests/send-gas-row-component.test.js b/ui/app/components/send_/send-content/send-gas-row/tests/send-gas-row-component.test.js
index e69de29bb..a96e8c8bb 100644
--- a/ui/app/components/send_/send-content/send-gas-row/tests/send-gas-row-component.test.js
+++ b/ui/app/components/send_/send-content/send-gas-row/tests/send-gas-row-component.test.js
@@ -0,0 +1,69 @@
+import React from 'react'
+import assert from 'assert'
+import { shallow } from 'enzyme'
+import sinon from 'sinon'
+import SendGasRow from '../send-gas-row.component.js'
+
+import SendRowWrapper from '../../send-row-wrapper/send-row-wrapper.component'
+import GasFeeDisplay from '../../../../send/gas-fee-display-v2'
+
+const propsMethodSpies = {
+ showCustomizeGasModal: sinon.spy(),
+}
+
+const MOCK_EVENT = { preventDefault: () => {} }
+
+describe('SendGasRow Component', function () {
+ let wrapper
+ let instance
+
+ beforeEach(() => {
+ wrapper = shallow(<SendGasRow
+ conversionRate={20}
+ convertedCurrency={'mockConvertedCurrency'}
+ gasLoadingError={false}
+ gasTotal={'mockGasTotal'}
+ showCustomizeGasModal={propsMethodSpies.showCustomizeGasModal}
+ />, { context: { t: str => str + '_t' } })
+ instance = wrapper.instance()
+ })
+
+ afterEach(() => {
+ propsMethodSpies.showCustomizeGasModal.resetHistory()
+ })
+
+ describe('render', () => {
+ it('should render a SendRowWrapper component', () => {
+ assert.equal(wrapper.find(SendRowWrapper).length, 1)
+ })
+
+ it('should pass the correct props to SendRowWrapper', () => {
+ const {
+ label,
+ } = wrapper.find(SendRowWrapper).props()
+
+ assert.equal(label, 'gasFee_t:')
+ })
+
+ it('should render a GasFeeDisplay as a child of the SendRowWrapper', () => {
+ assert(wrapper.find(SendRowWrapper).childAt(0).is(GasFeeDisplay))
+ })
+
+ it('should render the GasFeeDisplay with the correct props', () => {
+ const {
+ conversionRate,
+ convertedCurrency,
+ gasLoadingError,
+ gasTotal,
+ onClick,
+ } = wrapper.find(SendRowWrapper).childAt(0).props()
+ assert.equal(conversionRate,20)
+ assert.equal(convertedCurrency,'mockConvertedCurrency')
+ assert.equal(gasLoadingError, false)
+ assert.equal(gasTotal,'mockGasTotal')
+ assert.equal(propsMethodSpies.showCustomizeGasModal.callCount, 0)
+ onClick()
+ assert.equal(propsMethodSpies.showCustomizeGasModal.callCount, 1)
+ })
+ })
+})