describe("TodoCtrl", function() {
var scope;
/* This is typical jasmine+angular mock setup for the module */
beforeEach(angular.mock.module("yesod-example"));
beforeEach(angular.mock.inject(function($rootScope, $controller) {
scope = $rootScope.$new();
$controller("TodoCtrl", {$scope: scope});
}));
/* The tests */
it("should have two todos", function() {
expect(scope.todos.length).toBe(2);
expect(scope.todos[0].text).toBe("learn angular");
expect(scope.todos[0].done).toBe(true);
expect(scope.todos[1].text).toBe("integrate angular with your yesod app");
expect(scope.todos[1].done).toBe(false);
expect(scope.remaining()).toBe(1);
});
it("should add a todo", function() {
scope.todoText = "New Todo";
scope.addTodo();
expect(scope.todos.length).toBe(3);
expect(scope.todos[2].text).toBe("New Todo");
expect(scope.todos[2].done).toBe(false);
expect(scope.remaining()).toBe(2);
});
it("should archive", function() {
scope.archive();
expect(scope.todos.length).toBe(1);
expect(scope.todos[0].text).toBe("integrate angular with your yesod app");
expect(scope.todos[0].done).toBe(false);
expect(scope.remaining()).toBe(1);
});
});