首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在测试react-dnd时清除监视器?

如何在测试react-dnd时清除监视器?
EN

Stack Overflow用户
提问于 2016-07-08 03:49:33
回答 0查看 799关注 0票数 5

我正在尝试测试我的react-dnd实现,在我的一个drop函数中,我使用monitor.getInitialClientOffset()函数来获取偏移量,我想使用存根方法来返回一个特定的偏移量,然后我可以断言该偏移量,但我无法弄清楚这一点。在我的测试中我使用

代码语言:javascript
复制
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函数从测试后端传递给一个监视器,我在文档中看不到将它的存根版本传递给任何模拟方法的方法。

EN

回答

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38254121

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档