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) {
frameworks: ['jasmine'],
files: [
'bower_components/angular/angular.js',
'bower_components/angular-route/angular-route.js',
'bower_components/angular-mocks/angular-mocks.js',
'js/**/*.js',
'test/unit/**/*.js'
],
autoWatch: false,
singleRun: true,
autoWatch: true,
singleRun: false,
browsers: ['Chrome', 'Firefox']
});
};
......@@ -36,21 +36,24 @@
expect(scope.allChecked).toBeTruthy();
});
describe('the path', function () {
it('should default to "/"', function () {
expect(scope.location.path()).toBe('/');
describe('the filter', function () {
it('should default to ""', function () {
scope.$emit('$routeChangeSuccess');
expect(scope.status).toBe('');
expect(scope.statusFilter).toBeNull();
});
describe('being at /active', function () {
it('should filter non-completed', inject(function ($controller) {
ctrl = $controller('TodoCtrl', {
$scope: scope,
$location: {
path: function () { return '/active'; }
$routeParams: {
status: 'active'
}
});
scope.$digest();
scope.$emit('$routeChangeSuccess');
expect(scope.statusFilter.completed).toBeFalsy();
}));
});
......@@ -59,12 +62,12 @@
it('should filter completed', inject(function ($controller) {
ctrl = $controller('TodoCtrl', {
$scope: scope,
$location: {
path: function () { return '/completed'; }
$routeParams: {
status: 'completed'
}
});
scope.$digest();
scope.$emit('$routeChangeSuccess');
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