【发布时间】:2017-03-16 13:33:06
【问题描述】:
我正在尝试测试我的反应组件中的一种方法。单击按钮后会调用它,因此我可以使用酶进行模拟
it('clone should call handleCloneClick when clicked', () => {
const cloneButton = wrapper.find('#clone-btn');
cloneButton.simulate('click');
});
我的组件方法在这里:
_handleCloneClick(event) {
event.preventDefault();
event.stopPropagation();
this.props.handleClone(this.props.user.id);
}
当用户单击模拟中的按钮时正在调用 _handleCloneClick,我该如何测试它是否已成功调用?
【问题讨论】: