How it works...

Using npm test will produce a nice all green output, meaning that all of the tests have passed, as in the previous section; no need to see that again. In each individual test, we apply the technique that was described earlier: set up state, save a string version of it, apply the reducer or the mapper function, check it matches what you wanted it to produce, and check that the original state still matches the saved version.

Imagine that somebody accidentally modified the getProps() function that we tested so that instead of returning the regions, it returned the countries list, like so:

 Any unexpected change in a mapping (or reducer) function would be detected by our usage of the .toEqual() method,
which does a deep comparison of the produced and expected values

So, these simple tests can help you be safe against accidental changes – including the addition, removal, or modification of the expected values. This is a good safety net!

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

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