我正在测试以下React组件:
import React from 'react'
import AppBar from 'material-ui/lib/app-bar'
class NavBar extends React.Component {
render () {
return (
<div>
<AppBar
title='My NavBar Title'
/>
</div>
)
}
}
export default NavBar
它由一个material-ui AppBar组件组成。使用Tape and Enzyme,我想click
在AppBar
's上模拟一个IconButton
:
import NavBar from './NavBar'
import React from 'react'
import test from 'tape'
import { /* I don't know if it's `shallow` or `mount` */ } from 'enzyme'
test('NavBar component test', (assert) => {
test('simulating a click on the icon button', (assert) =>
// How do I do this?
// The following results in error:
// const wrapper = shallow(<NavBar />)
// wrapper.find('AppBar').find('IconButton').simulate('click')
assert.end()
})
assert.end()
})
我怎样才能正确地做到这一点?
Obs:我正在搜索,IconButton
因为根据React Dev Tools选项卡,这是呈现的图标按钮组件的名称。