In this book, we have tested the filling of text fields on a form, clicking on buttons, and the resulting HTML document. This makes us ready to test a traditional form-based request-response application, but typical modern applications are usually more complex than that as they make use of asynchronous HTTP requests, that somehow update the document without having to refresh it. This is because they use AJAX.
Our application emits AJAX requests when presented with the to-do item list page; a user can drag an item and drop it in the new position. The code that we placed in the public/js/todos.js
file catches the change and calls the server /todos/sort
URL, changing the item order in the database.
Let's see how we can use Zombie to test this drag-and-drop feature. The topics covered in this chapter include:
Using Zombie to trigger an AJAX call
Using Zombie to test the result of an AJAX call
By the end of this section, you will know how to use Zombie to test an application...