Skip to content

Commit 3be6ea3

Browse files
committed
Fix up tests and add PhantomJS back to test suite
1 parent 2d1be85 commit 3be6ea3

File tree

4 files changed

+27
-21
lines changed

4 files changed

+27
-21
lines changed

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
"karma-benchmark-reporter": "^0.1.1",
2323
"karma-firefox-launcher": "^0.1.3",
2424
"karma-jasmine": "^0.1.5",
25-
"node-karma-wrapper": "^0.2.2"
25+
"karma-phantomjs-launcher": "^1.0.0",
26+
"node-karma-wrapper": "^0.2.2",
27+
"phantomjs-prebuilt": "^2.1.4"
2628
}
2729
}

test/karma.conf.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module.exports = function(config) {
1212
'test/unit/*.js'
1313
],
1414
autoWatch: false,
15-
singleRun: true,
16-
browsers: ['Firefox']
15+
singleRun: false,
16+
browsers: ['Firefox', 'PhantomJS']
1717
});
1818
};

test/unit/todoAsCtrlSpec.js

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
(function () {
33
'use strict';
44

5-
describe('Todo Javascript Classy Controller', function () {
5+
describe('Todo Javascript Classy ControllerAs', function () {
66
var ctrl, scope;
77
var todoList;
88
var todoStorage = {
@@ -14,34 +14,39 @@
1414
this.storage = value;
1515
}
1616
};
17+
todoStorage.storage = [];
1718
var ctrlName = 'TodoAsControllerCtrl as todoCtrl';
1819

1920
// Load the module containing the app, only 'ng' is loaded by default.
2021
beforeEach(module('todomvc'));
2122

2223
beforeEach(inject(function ($controller, $rootScope) {
2324
scope = $rootScope.$new();
24-
ctrl = $controller(ctrlName, { $scope: scope });
25+
ctrl = $controller(ctrlName, { $scope: scope, todoStorage: todoStorage });
2526
}));
2627

27-
it('should not have any controller methods placed on the scope', function () {
28-
expect(scope.todos).toBeUndefined();
29-
expect(scope.editTodo).toBeUndefined();
30-
});
3128

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+
});
3534

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+
});
3938

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+
});
4347
});
4448

49+
4550
describe('the path', function () {
4651
it('should default to "/"', function () {
4752
expect(ctrl.$location.path()).toBe('/');
@@ -79,7 +84,6 @@
7984
var ctrl;
8085

8186
beforeEach(inject(function ($controller) {
82-
todoStorage.storage = [];
8387
ctrl = $controller(ctrlName, {
8488
$scope: scope,
8589
todoStorage: todoStorage

test/unit/todoCtrlSpec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@
1414
this.storage = value;
1515
}
1616
};
17+
todoStorage.storage = [];
1718
var ctrlName = 'TodoCtrl';
1819

1920
// Load the module containing the app, only 'ng' is loaded by default.
2021
beforeEach(module('todomvc'));
2122

2223
beforeEach(inject(function ($controller, $rootScope) {
2324
scope = $rootScope.$new();
24-
ctrl = $controller(ctrlName, { $scope: scope });
25+
ctrl = $controller(ctrlName, { $scope: scope, todoStorage: todoStorage });
2526
}));
2627

2728
it('should not have an edited Todo on start', function () {
@@ -74,7 +75,6 @@
7475
var ctrl;
7576

7677
beforeEach(inject(function ($controller) {
77-
todoStorage.storage = [];
7878
ctrl = $controller(ctrlName, {
7979
$scope: scope,
8080
todoStorage: todoStorage

0 commit comments

Comments
 (0)