问题描述
我将如何编写玩笑/酶单元测试来模拟行图标的点击处理程序,该处理程序仅在将鼠标悬停在[或]单击表行上时显示。
**code that I tried given below:-**
let wrapper = mount(<TableComponent {...mockData} />);
wrapper.find('.table-row').simulate('click');
wrapper.find('.row-action-icon').simulate('click')
//失败,因为row-action-icon未附加到DOM
有人可以帮助我解决此问题吗?
解决方法
我想出了上述情况的解决方案。它可能会帮助某人
dd=array('f',[[0]*5]*15)
-
类似地,我们可以使用“ @ testing-library / react”;
1) Mocking the component using jest mount. const wrapper = mount(<TableComponent {...mockData} />); 2) Trigger a mounse enter for the table row. wrapper.find('.table__body__row').at(0).props().onMouseEnter(); 3) Update the wrapper. It will intern update the DOM and insert the row icon. wrapper.update(); 4) Finally we can perform the action for the row icon wrapper.find('.row-actions-menu__trigger').simulate('click');