0
我要測試的這款終極版中間件代碼中間件我反應過來的應用程序:測試終極版與承諾
export const dispatchActionFromPromise = next => (promise, name) => {
promise.then(data => {
next({
type: `${name}_RECEIVED`,
data
});
},
error => {
return next({
type: `${name}_ERROR`,
error
});
});
};
const dataService = store => next => action => {
next(action);
switch (action.type) {
case GET_ORGANISATIONS:
dispatchActionFromPromise(next)(ApiClient.getOrganisations(), GET_ORGANISATIONS);
break;
default:
break;
}
};
export default dataService;
我想測試dispatchActionFromPromise()
這需要一個承諾(ApiClient.getOrganisations()
返回一個承諾)。
什麼是值得在這裏測試,如果有的話,什麼是最好的方法來測試這個?
我正在使用摩卡和柴進行測試。