Basic Async Action Creator Test
Create a basic test for testing async action creators.
We'll cover the following...
Jest handles async tests by allowing us to return a promise as the test’s result. If a promise is returned, the test runner will wait for the promise to resolve and only then continue to the next test:
it('FETCH_RECIPE', () => {
return store.dispatch(actions.fetchRecipe(100));
});
Since store.dispatch()
in this case returns a promise (remember, our fetchRecipe()
action creator returns a call to the axios
library), we ...