O'Reilly logo

Mastering JavaScript Functional Programming by Federico Kereki

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required