|
2 | 2 | (function () { |
3 | 3 | 'use strict'; |
4 | 4 |
|
5 | | - describe('Todo Javascript Classy Controller', function () { |
| 5 | + describe('Todo Javascript Classy ControllerAs', function () { |
6 | 6 | var ctrl, scope; |
7 | 7 | var todoList; |
8 | 8 | var todoStorage = { |
|
14 | 14 | this.storage = value; |
15 | 15 | } |
16 | 16 | }; |
| 17 | + todoStorage.storage = []; |
17 | 18 | var ctrlName = 'TodoAsControllerCtrl as todoCtrl'; |
18 | 19 |
|
19 | 20 | // Load the module containing the app, only 'ng' is loaded by default. |
20 | 21 | beforeEach(module('todomvc')); |
21 | 22 |
|
22 | 23 | beforeEach(inject(function ($controller, $rootScope) { |
23 | 24 | scope = $rootScope.$new(); |
24 | | - ctrl = $controller(ctrlName, { $scope: scope }); |
| 25 | + ctrl = $controller(ctrlName, { $scope: scope, todoStorage: todoStorage }); |
25 | 26 | })); |
26 | 27 |
|
27 | | - it('should not have any controller methods placed on the scope', function () { |
28 | | - expect(scope.todos).toBeUndefined(); |
29 | | - expect(scope.editTodo).toBeUndefined(); |
30 | | - }); |
31 | 28 |
|
32 | | - it('should not have an edited Todo on start', function () { |
33 | | - expect(ctrl.editedTodo).toBeNull(); |
34 | | - }); |
| 29 | + describe('init', function() { |
| 30 | + it('should not have any controller methods placed on the scope', function () { |
| 31 | + expect(scope.todos).toBeUndefined(); |
| 32 | + expect(scope.editTodo).toBeUndefined(); |
| 33 | + }); |
35 | 34 |
|
36 | | - it('should not have any Todos on start', function () { |
37 | | - expect(ctrl.todos.length).toBe(0); |
38 | | - }); |
| 35 | + it('should not have an edited Todo on start', function () { |
| 36 | + expect(ctrl.editedTodo).toBeNull(); |
| 37 | + }); |
39 | 38 |
|
40 | | - it('should have all Todos completed', function () { |
41 | | - scope.$digest(); |
42 | | - expect(ctrl.allChecked).toBeTruthy(); |
| 39 | + it('should not have any Todos on start', function () { |
| 40 | + expect(ctrl.todos.length).toBe(0); |
| 41 | + }); |
| 42 | + |
| 43 | + it('should have all Todos completed', function () { |
| 44 | + scope.$digest(); |
| 45 | + expect(ctrl.allChecked).toBeTruthy(); |
| 46 | + }); |
43 | 47 | }); |
44 | 48 |
|
| 49 | + |
45 | 50 | describe('the path', function () { |
46 | 51 | it('should default to "/"', function () { |
47 | 52 | expect(ctrl.$location.path()).toBe('/'); |
|
79 | 84 | var ctrl; |
80 | 85 |
|
81 | 86 | beforeEach(inject(function ($controller) { |
82 | | - todoStorage.storage = []; |
83 | 87 | ctrl = $controller(ctrlName, { |
84 | 88 | $scope: scope, |
85 | 89 | todoStorage: todoStorage |
|
0 commit comments