i want to test this redux middleware code for my react app:
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;
I want to test getOrganisations() which returns a promise (ApiClient.getOrganisations() returns a promise). What would be worth testing here, if any, and how would i best approach testing this?
I am using mocha and chai for my testing. Thanks
Aucun commentaire:
Enregistrer un commentaire