我在史诗中有以下内容:
def left(event):
print('clicked left')
def right(event):
print('clicked right')
root = tkinter.Tk()
button = tkinter.Button(root, text='click me')
button.pack()
button.bind('<Button-1>', left)
button.bind('<Button-3>', right)
root.mainloop()
动作:
mergeMap(result => concat(
of(fetchDone(result)),
of(dispatchActions(payload))
))
问题是在使用大理石的测试中,我需要能够检查匿名函数,因为const fetchDone = result => ({ type: "FETCH_DONE", payload: result });
function dispatchActions(payload) {
return dispatch => {
dispatch(doStuff(payload));
...
};
}
被视为匿名函数。我该怎么办?
dispatchActions
答案 0 :(得分:0)
作为一种解决方法,我正在做
function dispatchActions(payload) {
if (payload.callDispatches) {
return dispatch => {
dispatch(doStuff(payload));
...
};
}
return { type: "SOME_TYPE" };
}
然后在单元测试中,我只检查第二个收益。而且if条件测试可以在大理石以外的单独测试中处理。
这不是理想的方法,但现在可以解决此问题。不过,应该有某种方法可以使用弹珠来测试redux-thunk
。