Testing connected functions
Let’s finish by considering testing for functions connected in all the ways we’ve seen in this chapter. Given that the mechanisms for pipelining and composition are 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.
Testing pipelined functions
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 mocks and check whether they were called the correct number of times and whether they received the correct arguments each time. We will set them to provide a known answer to a call.
By doing this, we can check whether the output of a function becomes the input of the next function in the pipeline:
// pipetwo.test.ts describe("pipeTwo", function () { it("works with single arguments...