Continue the Design
The initial test list identified one task for adding a task and one for deleting a task.
- …
- addTask sends the data to the service
- deleteTask sends a delete request to the service
Let’s now focus on the addTask function.
Design addTask
When we analyzed the getTasks function, a single test for that function transformed into multiple tests in the test list. We can expect a similar result for the addTask function as well. Let’s analyze the addTask function.
First, we need the data for the new task. A new model newTask within the controller can store this data. We need to initialize this model to have a name property and a date property. We also need a function to convert the newTask to the JSON format expected by the server.
addTask ...
Get Test-Driving JavaScript Applications 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.