How test actions that use callApi()?
Closed this issue · 2 comments
BrunoQuaresma commented
How test actions that use callApi()?
randycoulman commented
We don't normally test our action creators directly, including those that use callApi
. They don't tend to have logic in them, so they don't need to be tested.
If I had a complex action creator that used callApi
, I'd inject a mock or spy version of callApi
and check that it was called with the arguments I expected. We use testdouble.js for this kind of thing, but you can also use sinon if you prefer.
If you're not familiar with this style of testing, the documentation for testdouble.js has lots of good information in it.
BrunoQuaresma commented
Thanks @randycoulman!