Successful Server Access
Explore how to test successful server access scenarios in Redux async middleware. Learn to mock network requests using axios, verify that API_FINISHED is dispatched after promise resolution, and ensure the correct data is set in the store by testing the SET_DATA action dispatch.
We'll cover the following...
We'll cover the following...
In the success scenario, we need to mock the axios library to return a successful response. We will be using the same mockRequest() utility introduced in the Async Action Creators lesson.
Our basic success tests need to check whether API_FINISHED is dispatched once the API is done. Test also check whether the success() action creator passes the response and is dispatched to the store once it is called.
// Success tests ...