我正在寻找一种方法来测试作为道具传递给React Redux中的React Bootstrap模式的函数,其生成方式与此类似:https://stackoverflow.com/a/35641680/4401847。
我需要测试通过mapDispatchToProps / mergeProps与Chai和Mocha作为道具传递的函数。我尝试这样做的方法是通过调度操作使模式弹出
这将是一个测试用例的例子,至少是它的第一行:
it("should dispatch an action when clicking a button", function (done) {
store.dispatch({
type: "modal/show",
modalType: "POST",
modalProps: {
mode: "add",
title "Create new post"
}
});
const modal = mount(<Provider store={store}><PostModal/><Provider/>);
setTimeOut(function() {
//I don't know how to access the functions passed as props via dispatchToProps and mergeProps.
});
});
非常感谢