Simon Hunt | 449630f | 2014-12-09 11:40:00 -0800 | [diff] [blame] | 1 | // Jasmine unit tests for ch03-controller.js |
| 2 | |
| 3 | describe('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 | }); |