Summary
This chapter has covered techniques for porting existing behavior from one place to another. In particular, it’s shown how worthwhile it can be to move business logic out of framework objects – such as form actions – and into plain JavaScript objects. Doing so makes the tests simpler.
In this case, our tests were no longer asynchronous, and no longer needed to use the complex performFormAction
helper.
Another benefit is that birthdayRepository
, along with its validation, can be reused in other places. That’s exactly what we’ll do in the next chapter, when we introduce new API endpoints that interact with the repository.