1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-29 07:16:36 +01:00
metamask-extension/ui/app/pages/send/send-content/send-gas-row/gas-fee-display/tests/gas-fee-display.component.test.js

63 lines
1.9 KiB
JavaScript
Raw Normal View History

import React from 'react'
import assert from 'assert'
2019-12-03 21:50:55 +01:00
import { shallow } from 'enzyme'
import GasFeeDisplay from '../gas-fee-display.component'
import UserPreferencedCurrencyDisplay from '../../../../../../components/app/user-preferenced-currency-display'
2018-06-21 09:03:19 +02:00
import sinon from 'sinon'
const propsMethodSpies = {
showCustomizeGasModal: sinon.spy(),
onReset: sinon.spy(),
}
describe('GasFeeDisplay Component', function () {
let wrapper
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' } })
})
afterEach(function () {
propsMethodSpies.showCustomizeGasModal.resetHistory()
})
it('should render a CurrencyDisplay component', function () {
assert.equal(wrapper.find(UserPreferencedCurrencyDisplay).length, 2)
})
it('should render the CurrencyDisplay with the correct props', function () {
const {
type,
2018-06-21 09:03:19 +02:00
value,
} = wrapper.find(UserPreferencedCurrencyDisplay).at(0).props()
assert.equal(type, 'PRIMARY')
assert.equal(value, 'mockGasTotal')
})
it('should render the reset button with the correct props', function () {
const {
onClick,
className,
2018-06-21 09:03:19 +02:00
} = wrapper.find('button').props()
assert.equal(className, 'gas-fee-reset')
assert.equal(propsMethodSpies.onReset.callCount, 0)
onClick()
assert.equal(propsMethodSpies.onReset.callCount, 1)
})
it('should render the reset button with the correct text', function () {
assert.equal(wrapper.find('button').text(), 'reset_t')
})
})
})