1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-24 12:23:39 +02:00
metamask-extension/ui/app/pages/send/send-content/send-gas-row/gas-fee-display/tests/gas-fee-display.component.test.js
Thomas Huang 5d1c9313db
Various component tests and some conditional statements (#7765)
* Various component tests and some conditional statements

Conditional in account-menu in removeAccount when keyring sometimes is not initially provideed
Conditional on unlock-page when there is no target.getBoundingClientRect on the element.

* Update helpers

* Remove component debugging

* Add default params for render helpers

* Remove stubComponent for old Mascot
Changes in https://github.com/MetaMask/metamask-extension/pull/7893 has prevented the need to stub it out.

Change logout to lock in account-menu test
2020-01-30 11:34:45 -08:00

64 lines
1.8 KiB
JavaScript

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