1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-12 20:57:12 +01:00
metamask-extension/ui/app/components/confirm-page-container/confirm-detail-row/tests/confirm-detail-row.component.test.js

65 lines
2.4 KiB
JavaScript
Raw Normal View History

2018-07-25 20:57:41 +02:00
import React from 'react'
import assert from 'assert'
import { shallow } from 'enzyme'
import ConfirmDetailRow from '../confirm-detail-row.component.js'
import sinon from 'sinon'
const propsMethodSpies = {
onHeaderClick: sinon.spy(),
}
2018-07-26 01:31:33 +02:00
describe('Confirm Detail Row Component', function () {
2018-07-25 20:57:41 +02:00
let wrapper
beforeEach(() => {
wrapper = shallow(<ConfirmDetailRow
errorType={'mockErrorType'}
label={'mockLabel'}
showError={false}
2018-07-26 01:26:30 +02:00
fiatText = {'mockFiatText'}
ethText = {'mockEthText'}
fiatTextColor= {'mockColor'}
2018-07-25 20:57:41 +02:00
onHeaderClick= {propsMethodSpies.onHeaderClick}
headerText = {'mockHeaderText'}
headerTextClassName = {'mockHeaderClass'}
/>)
})
2018-07-26 01:31:33 +02:00
describe('render', () => {
2018-07-25 20:57:41 +02:00
it('should render a div with a confirm-detail-row class', () => {
assert.equal(wrapper.find('div.confirm-detail-row').length, 1)
})
it('should render the label as a child of the confirm-detail-row__label', () => {
assert.equal(wrapper.find('.confirm-detail-row > .confirm-detail-row__label').childAt(0).text(), 'mockLabel')
})
it('should render the headerText as a child of the confirm-detail-row__header-text', () => {
assert.equal(wrapper.find('.confirm-detail-row__details > .confirm-detail-row__header-text').childAt(0).text(), 'mockHeaderText')
})
it('should render the fiatText as a child of the confirm-detail-row__fiat', () => {
2018-07-26 01:26:30 +02:00
assert.equal(wrapper.find('.confirm-detail-row__details > .confirm-detail-row__fiat').childAt(0).text(), 'mockFiatText')
2018-07-25 20:57:41 +02:00
})
it('should render the ethText as a child of the confirm-detail-row__eth', () => {
2018-07-26 01:26:30 +02:00
assert.equal(wrapper.find('.confirm-detail-row__details > .confirm-detail-row__eth').childAt(0).text(), 'mockEthText')
2018-07-25 20:57:41 +02:00
})
it('should set the fiatTextColor on confirm-detail-row__fiat', () => {
assert.equal(wrapper.find('.confirm-detail-row__fiat').props().style.color, 'mockColor')
})
it('should assure the confirm-detail-row__header-text classname is correct', () => {
assert.equal(wrapper.find('.confirm-detail-row__header-text').props().className, 'confirm-detail-row__header-text mockHeaderClass')
})
it('should call onHeaderClick when headerText div gets clicked', () => {
wrapper.find('.confirm-detail-row__header-text').props().onClick()
assert.equal(assert.equal(propsMethodSpies.onHeaderClick.callCount, 1))
})
})
})