Commit d6a83291 authored by Pascal Hartig's avatar Pascal Hartig

AngularJS: Upgrade unit tests for ngRoute

parent f1f976e2
...@@ -6,12 +6,13 @@ module.exports = function (config) { ...@@ -6,12 +6,13 @@ module.exports = function (config) {
frameworks: ['jasmine'], frameworks: ['jasmine'],
files: [ files: [
'bower_components/angular/angular.js', 'bower_components/angular/angular.js',
'bower_components/angular-route/angular-route.js',
'bower_components/angular-mocks/angular-mocks.js', 'bower_components/angular-mocks/angular-mocks.js',
'js/**/*.js', 'js/**/*.js',
'test/unit/**/*.js' 'test/unit/**/*.js'
], ],
autoWatch: false, autoWatch: true,
singleRun: true, singleRun: false,
browsers: ['Chrome', 'Firefox'] browsers: ['Chrome', 'Firefox']
}); });
}; };
...@@ -36,21 +36,24 @@ ...@@ -36,21 +36,24 @@
expect(scope.allChecked).toBeTruthy(); expect(scope.allChecked).toBeTruthy();
}); });
describe('the path', function () { describe('the filter', function () {
it('should default to "/"', function () { it('should default to ""', function () {
expect(scope.location.path()).toBe('/'); scope.$emit('$routeChangeSuccess');
expect(scope.status).toBe('');
expect(scope.statusFilter).toBeNull();
}); });
describe('being at /active', function () { describe('being at /active', function () {
it('should filter non-completed', inject(function ($controller) { it('should filter non-completed', inject(function ($controller) {
ctrl = $controller('TodoCtrl', { ctrl = $controller('TodoCtrl', {
$scope: scope, $scope: scope,
$location: { $routeParams: {
path: function () { return '/active'; } status: 'active'
} }
}); });
scope.$digest(); scope.$emit('$routeChangeSuccess');
expect(scope.statusFilter.completed).toBeFalsy(); expect(scope.statusFilter.completed).toBeFalsy();
})); }));
}); });
...@@ -59,12 +62,12 @@ ...@@ -59,12 +62,12 @@
it('should filter completed', inject(function ($controller) { it('should filter completed', inject(function ($controller) {
ctrl = $controller('TodoCtrl', { ctrl = $controller('TodoCtrl', {
$scope: scope, $scope: scope,
$location: { $routeParams: {
path: function () { return '/completed'; } status: 'completed'
} }
}); });
scope.$digest(); scope.$emit('$routeChangeSuccess');
expect(scope.statusFilter.completed).toBeTruthy(); expect(scope.statusFilter.completed).toBeTruthy();
})); }));
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment