我在史诗中有以下内容:
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
它被视为匿名函数。我怎么做?
const values = {
...
b: { type: "FETCH_DONE", payload: expected },
c: NEEDS TO BE ANONYMOUS
};
...
const output$ = fetchApi(action$, state$);
// This fails due to the anonymous function
expectObservable(output$).toBe('---(bc)--', values);