问题描述
我从 react-toastify 库构建了一个 Toast 和 toastemitter。我需要验证单击按钮时是否生成了吐司。我已经默认 bodyClassname 为“my-toast”,所以当我模拟点击按钮时,我应该会在 DOM 中看到它?
const props = {
containerId: 'toast-id',limit: 3,}
describe('Toast Component',() => {
it('renders component with props',() => {
const component = mount(
<>
<Toast {...props} />
<button
id="emit-toast"
type="button"
onClick={() => emitToast('Test','success')}
>
Open
</button>
</>,)
expect(component.find('.my-toast')).toHaveLength(0)
const toastemitter = component.find('#emit-toast')
toastemitter.simulate('click')
expect(component.find('.my-toast')).toHaveLength(1)
})
})
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)