Now you can test the second half of networking. The trick is to use a test spy to capture the closure. Then call the closure with various arguments.
You’ve also seen how to use test expectations to test asynchronous code. Create an expectation, fulfill it in a completion closure, and wait for it.
In the next chapter, let’s get back to handling user input. We’ll explore text fields, which will show us how to test delegate methods.