blob: 58a37f2ea198611ebf95fe7fdd68a78915891b81 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
'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.hash = '/foo?a=b';
scope.$digest();
expect($routeParams).toEqual({a:'b'});
$location.hash = '/bar/123?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.hash = '/foo?a=b';
scope.$digest();
expect(scope.$service('$routeParams')).toBe(firstRouteParams);
$location.hash = '/bar/123?x=abc';
scope.$digest();
expect(scope.$service('$routeParams')).toBe(firstRouteParams);
});
});
|