angular.js/test/service/routeParamsSpec.js
Vojta Jina 22cb600280 fix($route): update $route to reflect $location changes
* update $route to reflect new $location
* add some more unit tests to $route
* fix some other failing unit tests
* redirect overrides the url now

Breaks $route custom redirect fn has only 3 params now
2011-09-08 23:00:59 +02:00

41 lines
1.2 KiB
JavaScript

'use strict';
describe('$routeParams', function(){
it('should publish the params into a service', function(){
var scope = angular.scope(),
$location = scope.$service('$location'),
$route = scope.$service('$route'),
$routeParams = scope.$service('$routeParams');
$route.when('/foo');
$route.when('/bar/:barId');
$location.path('/foo').search('a=b');
scope.$digest();
expect($routeParams).toEqual({a:'b'});
$location.path('/bar/123').search('x=abc');
scope.$digest();
expect($routeParams).toEqual({barId:'123', x:'abc'});
});
it('should preserve object identity during route reloads', function(){
var scope = angular.scope(),
$location = scope.$service('$location'),
$route = scope.$service('$route'),
$routeParams = scope.$service('$routeParams'),
firstRouteParams = $routeParams;
$route.when('/foo');
$route.when('/bar/:barId');
$location.path('/foo').search('a=b');
scope.$digest();
expect(scope.$service('$routeParams')).toBe(firstRouteParams);
$location.path('/bar/123').search('x=abc');
scope.$digest();
expect(scope.$service('$routeParams')).toBe(firstRouteParams);
});
});