0

In my React-redux app, one of my action creators returns like this:

return {
        type : GET_RESULTS,
        payload: response
    };

I am trying to write a test where I just call the action creator externally and mock its arguments since its just a pure function.

In my app, the middleware redux-promise directly handles the promise to payload conversion in the store and passes it to the reducers.

The issue is that, the payload in the above returned object is a promise returned by axios GET call. So, in my test file, where I call it, I will get a promise, but I need to get its real payload value, the one after the promise is complete.

How do I do this?

Meticulous
  • 115
  • 2
  • 12
  • 2
    use the standard promise's `.then` method – Jaromanda X Aug 10 '17 at 23:31
  • Oh.. I am very new to promises, I am unsure exactly how the async nature of the promise will affect my test. But I hope my question was clear. Assuming I have an `action`, I am going to explicitly call the `action` as a function and then use its `promise` object to get the resolved value. Will it work in this case? – Meticulous Aug 10 '17 at 23:46

0 Answers0