如何使用Jest模拟对Awesome字体图标的点击?

问题描述 投票:0回答:1

我正在通过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()
})
reactjs jestjs enzyme
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.