Testing reducers and mappings

After testing the components, we are now moving on to a simpler set of tests: first, reducers; and then mappings such as mapStateToProps() and mapDispatchToProps(). Why are these tests easier to write? Because in all of these cases, we are dealing with pure functions, without side effects, that produce their output based only on their inputs. We already dealt with these sort of functions earlier in this book when we did testing for Node, so now we'll make do with a short section. The only particular care we'll have is to verify that no function (for example, a reducer) attempts to modify the state, but other than that, it's simple to test all the way. In this recipe, let's look at the different kind of tests we'll need for reducers and mappings.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.81.240