2018-06-21 08:43:48 +02:00
|
|
|
import React from 'react'
|
|
|
|
import assert from 'assert'
|
2019-12-03 21:50:55 +01:00
|
|
|
import { shallow } from 'enzyme'
|
2018-06-21 08:43:48 +02:00
|
|
|
import GasFeeDisplay from '../gas-fee-display.component'
|
2019-04-17 21:15:13 +02:00
|
|
|
import UserPreferencedCurrencyDisplay from '../../../../../../components/app/user-preferenced-currency-display'
|
2018-06-21 09:03:19 +02:00
|
|
|
import sinon from 'sinon'
|
2018-06-21 08:43:48 +02:00
|
|
|
|
|
|
|
const propsMethodSpies = {
|
|
|
|
showCustomizeGasModal: sinon.spy(),
|
2018-11-05 18:01:46 +01:00
|
|
|
onReset: sinon.spy(),
|
2018-06-21 08:43:48 +02:00
|
|
|
}
|
|
|
|
|
2018-11-05 18:01:46 +01:00
|
|
|
describe('GasFeeDisplay Component', function () {
|
2018-06-21 08:43:48 +02:00
|
|
|
let wrapper
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('render', function () {
|
|
|
|
beforeEach(function () {
|
|
|
|
wrapper = shallow((
|
|
|
|
<GasFeeDisplay
|
|
|
|
conversionRate={20}
|
|
|
|
gasTotal="mockGasTotal"
|
|
|
|
primaryCurrency="mockPrimaryCurrency"
|
|
|
|
convertedCurrency="mockConvertedCurrency"
|
|
|
|
showGasButtonGroup={propsMethodSpies.showCustomizeGasModal}
|
|
|
|
onReset={propsMethodSpies.onReset}
|
|
|
|
/>
|
2020-02-15 21:34:12 +01:00
|
|
|
), { context: { t: (str) => str + '_t' } })
|
2020-02-11 17:51:13 +01:00
|
|
|
})
|
2018-06-21 08:43:48 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
afterEach(function () {
|
|
|
|
propsMethodSpies.showCustomizeGasModal.resetHistory()
|
|
|
|
})
|
2018-06-21 08:43:48 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('should render a CurrencyDisplay component', function () {
|
2018-10-17 01:03:29 +02:00
|
|
|
assert.equal(wrapper.find(UserPreferencedCurrencyDisplay).length, 2)
|
2018-06-21 08:43:48 +02:00
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('should render the CurrencyDisplay with the correct props', function () {
|
2018-06-21 08:43:48 +02:00
|
|
|
const {
|
2018-10-17 01:03:29 +02:00
|
|
|
type,
|
2018-06-21 09:03:19 +02:00
|
|
|
value,
|
2018-10-17 01:03:29 +02:00
|
|
|
} = wrapper.find(UserPreferencedCurrencyDisplay).at(0).props()
|
|
|
|
assert.equal(type, 'PRIMARY')
|
2018-06-21 08:43:48 +02:00
|
|
|
assert.equal(value, 'mockGasTotal')
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('should render the reset button with the correct props', function () {
|
2018-06-21 08:43:48 +02:00
|
|
|
const {
|
|
|
|
onClick,
|
2018-09-20 06:16:43 +02:00
|
|
|
className,
|
2018-06-21 09:03:19 +02:00
|
|
|
} = wrapper.find('button').props()
|
2018-09-20 06:16:43 +02:00
|
|
|
assert.equal(className, 'gas-fee-reset')
|
2018-11-05 18:01:46 +01:00
|
|
|
assert.equal(propsMethodSpies.onReset.callCount, 0)
|
2018-06-21 08:43:48 +02:00
|
|
|
onClick()
|
2018-11-05 18:01:46 +01:00
|
|
|
assert.equal(propsMethodSpies.onReset.callCount, 1)
|
2018-06-21 08:43:48 +02:00
|
|
|
})
|
2018-09-20 06:16:43 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('should render the reset button with the correct text', function () {
|
2018-09-20 06:16:43 +02:00
|
|
|
assert.equal(wrapper.find('button').text(), 'reset_t')
|
|
|
|
})
|
2018-06-21 08:43:48 +02:00
|
|
|
})
|
|
|
|
})
|