Skip to content

Instantly share code, notes, and snippets.

@twelverobots
Created November 7, 2013 01:33
Show Gist options
  • Save twelverobots/7347428 to your computer and use it in GitHub Desktop.
Save twelverobots/7347428 to your computer and use it in GitHub Desktop.
'use strict';
describe('Controller: TodoListController handles Todo Lists', function () {
// load the controller's module
beforeEach(module('todosApp'));
var todoListCtrl,
scope;
// Initialize the controller and a mock scope
beforeEach(inject(function ($controller, $rootScope) {
scope = $rootScope.$new();
todoListCtrl = $controller('TodoListController', {
$scope: scope
});
}));
it('and adds default text to the scope ', function () {
expect(scope.newListName).toBeDefined();
});
it('and will tell us how many characters are left in the field', function () {
scope.newListName = "Test Text";
todoListCtrl.setMaxLength(200);
expect(scope.charsLeft()).toBe(191);
expect(todoListCtrl.getMaxLength()).toBe(200);
});
it('and will create a new list', function () {
scope.newListName = 'Test List';
scope.addList();
expect(scope.lists[0].name).toBe('Test List');
expect(Array.isArray(scope.lists)).toBe(true);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment