How to do it...

We'll have to test the reducers and mappings, so let's start by thinking about how you would test a reducer. There are two key things to verify: first, that given an input state, it produces a correct output state, and second, that the reducer doesn't modify the original state. The first condition is pretty obvious, but the second can easily be missed – and a reducer that modifies the current state can produce hard-to-find bugs.

Let's look at how we could test our countries and regions application's reducer. First, since all tests are analog, we'll just see a couple of them, for two of all the possible actions – but of course, you want to test all of the actions, right? We'll also include another test to verify that for unknown ...

Get Modern JavaScript Web Development Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.