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.
64 lines
1.8 KiB
64 lines
1.8 KiB
7 years ago
|
import React from 'react'
|
||
|
import assert from 'assert'
|
||
5 years ago
|
import { shallow } from 'enzyme'
|
||
7 years ago
|
import GasFeeDisplay from '../gas-fee-display.component'
|
||
6 years ago
|
import UserPreferencedCurrencyDisplay from '../../../../../../components/app/user-preferenced-currency-display'
|
||
7 years ago
|
import sinon from 'sinon'
|
||
7 years ago
|
|
||
|
|
||
|
const propsMethodSpies = {
|
||
|
showCustomizeGasModal: sinon.spy(),
|
||
6 years ago
|
onReset: sinon.spy(),
|
||
7 years ago
|
}
|
||
|
|
||
6 years ago
|
describe('GasFeeDisplay Component', function () {
|
||
7 years ago
|
let wrapper
|
||
|
|
||
|
beforeEach(() => {
|
||
5 years ago
|
wrapper = shallow((
|
||
|
<GasFeeDisplay
|
||
|
conversionRate={20}
|
||
|
gasTotal="mockGasTotal"
|
||
|
primaryCurrency="mockPrimaryCurrency"
|
||
|
convertedCurrency="mockConvertedCurrency"
|
||
|
showGasButtonGroup={propsMethodSpies.showCustomizeGasModal}
|
||
|
onReset={propsMethodSpies.onReset}
|
||
|
/>
|
||
5 years ago
|
), { context: { t: str => str + '_t' } })
|
||
7 years ago
|
})
|
||
|
|
||
|
afterEach(() => {
|
||
|
propsMethodSpies.showCustomizeGasModal.resetHistory()
|
||
|
})
|
||
|
|
||
|
describe('render', () => {
|
||
|
it('should render a CurrencyDisplay component', () => {
|
||
6 years ago
|
assert.equal(wrapper.find(UserPreferencedCurrencyDisplay).length, 2)
|
||
7 years ago
|
})
|
||
|
|
||
|
it('should render the CurrencyDisplay with the correct props', () => {
|
||
|
const {
|
||
6 years ago
|
type,
|
||
7 years ago
|
value,
|
||
6 years ago
|
} = wrapper.find(UserPreferencedCurrencyDisplay).at(0).props()
|
||
|
assert.equal(type, 'PRIMARY')
|
||
7 years ago
|
assert.equal(value, 'mockGasTotal')
|
||
|
})
|
||
|
|
||
6 years ago
|
it('should render the reset button with the correct props', () => {
|
||
7 years ago
|
const {
|
||
|
onClick,
|
||
6 years ago
|
className,
|
||
7 years ago
|
} = wrapper.find('button').props()
|
||
6 years ago
|
assert.equal(className, 'gas-fee-reset')
|
||
6 years ago
|
assert.equal(propsMethodSpies.onReset.callCount, 0)
|
||
7 years ago
|
onClick()
|
||
6 years ago
|
assert.equal(propsMethodSpies.onReset.callCount, 1)
|
||
7 years ago
|
})
|
||
6 years ago
|
|
||
|
it('should render the reset button with the correct text', () => {
|
||
|
assert.equal(wrapper.find('button').text(), 'reset_t')
|
||
|
})
|
||
7 years ago
|
})
|
||
|
})
|