1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-25 12:52:33 +02:00
metamask-extension/ui/app/components/send/send-content/send-gas-row/gas-fee-display/test/gas-fee-display.component.test.js

54 lines
1.5 KiB
JavaScript
Raw Normal View History

import React from 'react'
import assert from 'assert'
import {shallow} from 'enzyme'
import GasFeeDisplay from '../gas-fee-display.component'
import UserPreferencedCurrencyDisplay from '../../../../../user-preferenced-currency-display'
2018-06-21 09:03:19 +02:00
import sinon from 'sinon'
const propsMethodSpies = {
showCustomizeGasModal: sinon.spy(),
}
2018-07-03 00:49:33 +02:00
describe('SendGasRow Component', function () {
let wrapper
beforeEach(() => {
wrapper = shallow(<GasFeeDisplay
conversionRate={20}
gasTotal={'mockGasTotal'}
onClick={propsMethodSpies.showCustomizeGasModal}
primaryCurrency={'mockPrimaryCurrency'}
convertedCurrency={'mockConvertedCurrency'}
/>, {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,
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 Button with the correct props', () => {
const {
onClick,
2018-06-21 09:03:19 +02:00
} = wrapper.find('button').props()
assert.equal(propsMethodSpies.showCustomizeGasModal.callCount, 0)
onClick()
assert.equal(propsMethodSpies.showCustomizeGasModal.callCount, 1)
})
})
})