在自定义事件上可以使用酶的.simulate()方法。例如:
// Code
<Element onFoo={someFunction}></Elements>
// Test
const element = shallow(<Element>);
element.simulate('foo');
Run Code Online (Sandbox Code Playgroud)
这是应该使用酶测试自定义事件的方式,还是使用s.th的更好方法?喜欢:
//Test
const element = shallow(<Element>);
element.props.onFoo()
Run Code Online (Sandbox Code Playgroud)