我正在尝试测试我的react-dnd实现,在我的一个drop函数中,我使用monitor.getInitialClientOffset()函数来获取偏移量,我想使用存根方法来返回一个特定的偏移量,然后我可以断言该偏移量,但我无法弄清楚这一点。在我的测试中我使用
const WrappedContext = wrapInTestContext(ContextArea);
const page = mount(<WrappedContext />);
const manager = page.get(0).getManager();
const backend = manager.getBackend();
// Couple finds to get the right source and target ids
backend.simulateBeginDrag([sourceId])
backend.simulateHover([targetId])
backend.simulateDrop();
backend.simulateEndDrag();(这是使用来自https://gaearon.github.io/react-dnd/docs-testing.html的标准wrapInTestContext )
drop函数从测试后端传递给一个监视器,我在文档中看不到将它的存根版本传递给任何模拟方法的方法。
https://stackoverflow.com/questions/38254121
复制相似问题