Let's add some tests to the test/todos.js
file.
We start off by adding a new describe scope before the end of the
Todo list
scope:describe('When there are some items on the list', function() {
This new scope allows us to setup a to-do item fixture list in the database before any test inside this scope is run.
Now, let's add this new
beforeEach
hook inside the new scope:beforeEach(function(done) { // insert todo items db.insert(fixtures.todos, fixtures.user.email, done); });
Then we start the test by logging in:
it('should allow me to reorder items using drag and drop', login(function(browser, done) {
We start the test by making sure that we have three to-do items in our item list page:
var items = browser.queryAll('#todo-list tr'); assert.equal(items.length, 3, 'Should have 3 items and has ' + items.length);
Then we declare a helper function that will assist us in verifying the contents of that list:
function expectOrder(order) { var itemTexts = browser.queryAll...