blob: b2d4947be55ac66cfe2fc51b18a08027aafd7c11 [file] [log] [blame]
Simon Hunt449630f2014-12-09 11:40:00 -08001// Jasmine unit tests for ch03-controller.js
2
3describe('Controller: ListCtrl', function () {
4 // instantiate a new version of my module before each test
5 beforeEach(module('notesApp'));
6
7 var ctrl;
8
9 // before each unit test, instantiate a new instance of the controller
10 beforeEach(inject(function ($controller) {
11 ctrl = $controller('ListCtrl');
12 }));
13
14 it('should have items available on load', function () {
15 expect(ctrl.items).toEqual([
16 {id: 1, label: 'First', done: true},
17 {id: 2, label: 'Second', done: false}
18 ]);
19 });
20
21 it('should have highlight items based on state', function () {
22 var item = {id: 1, label: 'First', done: true};
23
24 var actualClass = ctrl.getDoneClass(item);
25 expect(actualClass.finished).toBeTruthy();
26 expect(actualClass.unfinished).toBeFalsy();
27
28 item.done = false;
29
30 actualClass = ctrl.getDoneClass(item);
31 expect(actualClass.finished).toBeFalsy();
32 expect(actualClass.unfinished).toBeTruthy();
33 });
34
35});