Let's say I want to test the following for example:
import {fetchResourceFromBackend} from './myfetch';
const fetchSomething = (dispatch) => {
dispatch(2);
return fetchResourceFromBackend('/api/abc').then( result => {
dispatch(3);
});
};
fetchResourceFromBackend
is some complicated function. How can I test this, and not be affected by fetchResourceFromBackend
code (any pattern or tool recommendations, I use mocha
and sinon
but cannot achieve)?
Is my only option to provide fetchResourceFromBackend
as an argument to fetchSomething
so I can mock it?