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 give examples for both of them and they won't differ, other than the 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 seeing how to test the pipeTwo() function, because the setup will be similar for pipeline(). We need to create some spies and then check whether they were called the right number of times and whether they received the correct arguments each time. We will set the spies so they will provide a known answer to a call, so we can see if the output of ...

Get Mastering Javascript Functional Programming 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.