My team recently started working on a project that uses redux-promise. The payload in each action is an axios call, like this:
function fetchUsers() {
return {
type: actionTypes.FETCH_USERS,
payload: axios.post('users')
}
}
Redux-promise takes care of dispatching "a copy of the action with the resolved value of the promise" (their words). The reducer expects the data, not a promise:
function userReducer(state, action) {
switch (action.type) {
case actionTypes.FETCH_USERS:
return action.payload.data
default:
return state
}
}
The application works as intended, but writing tests has been a challenge. What's are the best practices for writing tests in this environment? I'd like to write tests for the action creator and for the reducer.