You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
72 lines
2.3 KiB
72 lines
2.3 KiB
6 years ago
|
import React from 'react'
|
||
|
import assert from 'assert'
|
||
|
import { shallow } from 'enzyme'
|
||
|
import sinon from 'sinon'
|
||
|
import TokenBalance from '../../token-balance'
|
||
|
import CurrencyDisplay from '../../currency-display'
|
||
|
import { SEND_ROUTE } from '../../../routes'
|
||
6 years ago
|
import TransactionViewBalance from '../transaction-view-balance.component'
|
||
6 years ago
|
|
||
|
const propsMethodSpies = {
|
||
|
showDepositModal: sinon.spy(),
|
||
|
}
|
||
|
|
||
|
const historySpies = {
|
||
|
push: sinon.spy(),
|
||
|
}
|
||
|
|
||
|
const t = (str1, str2) => str2 ? str1 + str2 : str1
|
||
|
|
||
6 years ago
|
describe('TransactionViewBalance Component', () => {
|
||
6 years ago
|
afterEach(() => {
|
||
|
propsMethodSpies.showDepositModal.resetHistory()
|
||
|
historySpies.push.resetHistory()
|
||
|
})
|
||
|
|
||
|
it('should render ETH balance properly', () => {
|
||
6 years ago
|
const wrapper = shallow(<TransactionViewBalance
|
||
6 years ago
|
showDepositModal={propsMethodSpies.showDepositModal}
|
||
|
history={historySpies}
|
||
|
network="3"
|
||
|
ethBalance={123}
|
||
|
fiatBalance={456}
|
||
|
currentCurrency="usd"
|
||
|
/>, { context: { t } })
|
||
|
|
||
6 years ago
|
assert.equal(wrapper.find('.transaction-view-balance').length, 1)
|
||
|
assert.equal(wrapper.find('.transaction-view-balance__button').length, 2)
|
||
6 years ago
|
assert.equal(wrapper.find(CurrencyDisplay).length, 2)
|
||
|
|
||
6 years ago
|
const buttons = wrapper.find('.transaction-view-balance__buttons')
|
||
6 years ago
|
assert.equal(propsMethodSpies.showDepositModal.callCount, 0)
|
||
|
buttons.childAt(0).simulate('click')
|
||
|
assert.equal(propsMethodSpies.showDepositModal.callCount, 1)
|
||
|
assert.equal(historySpies.push.callCount, 0)
|
||
|
buttons.childAt(1).simulate('click')
|
||
|
assert.equal(historySpies.push.callCount, 1)
|
||
|
assert.equal(historySpies.push.getCall(0).args[0], SEND_ROUTE)
|
||
|
})
|
||
|
|
||
|
it('should render token balance properly', () => {
|
||
|
const token = {
|
||
|
address: '0x35865238f0bec9d5ce6abff0fdaebe7b853dfcc5',
|
||
|
decimals: '2',
|
||
|
symbol: 'ABC',
|
||
|
}
|
||
|
|
||
6 years ago
|
const wrapper = shallow(<TransactionViewBalance
|
||
6 years ago
|
showDepositModal={propsMethodSpies.showDepositModal}
|
||
|
history={historySpies}
|
||
|
network="3"
|
||
|
ethBalance={123}
|
||
|
fiatBalance={456}
|
||
|
currentCurrency="usd"
|
||
|
selectedToken={token}
|
||
|
/>, { context: { t } })
|
||
|
|
||
6 years ago
|
assert.equal(wrapper.find('.transaction-view-balance').length, 1)
|
||
|
assert.equal(wrapper.find('.transaction-view-balance__button').length, 1)
|
||
6 years ago
|
assert.equal(wrapper.find(TokenBalance).length, 1)
|
||
|
})
|
||
|
})
|