blob: 8cdf3af319ea74ebcc7b532e90a0820132bb195e (
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.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);
  });
});
 |