我正在通过Jest测试,正在尝试测试对Font Awesome Icon的点击。我尝试了不同的方法来查找“节点”,但是出现了“方法“模拟”应在1个节点上运行,而是找到0个错误”的错误消息。任何见解都会有所帮助。
当我尝试对component.find()
进行不同的输入时出现的错误是:Method “simulate” is meant to be run on 1 node. 0 found instead.
StringEditor]
const clearInput = () => {
onRemove()
}
render (
...
<FontAwesomeIcon icon={['fal', 'times-circle']} className="clear-button"
onClick={clearInput} /> : null`
)
onRemove
是一个回调函数。
it('should call clearInput thus onRemove', () =>{
const onRemove= jest.fn()
const component = mount(<StringEditor {...defaultProps} onRemove={onRemove} />)
component.find('<dont know what to put>').simulate('click')
expect(saveValueFn).toBeCalled()
})