Testing composed functions

Let's finish this chapter by giving some consideration to testing for pipelined or composed functions. Given that the mechanism for both operations is similar, we will look at examples of both. They won't differ, other than their logical differences due to the left-to-right or right-to-left order of function evaluation.

When it comes to pipelining, we can start by looking at how to test the pipeTwo() function since the setup will be similar to pipeline(). We need to create some spies and check whether they were called the correct number of times and whether they received the correct arguments each time. We will set the spies so that they provide a known answer to a call. By doing this, we can check whether the output ...

Get Mastering JavaScript Functional Programming - Second Edition 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.