diff options
| author | Misko Hevery | 2011-08-23 22:30:14 -0700 |
|---|---|---|
| committer | Igor Minar | 2011-08-31 14:31:23 -0700 |
| commit | ad3cc16eef0a13844e6e05abcb18c46a370f0814 (patch) | |
| tree | 48c90bd555d26eef0164b7deeff5417e300a6536 /test/service/routeParamsSpec.js | |
| parent | 08d09ecbaa07564bf3cf6a62e0be4c41b355d23b (diff) | |
| download | angular.js-ad3cc16eef0a13844e6e05abcb18c46a370f0814.tar.bz2 | |
feat($route): add events before/after route change
BREAKING CHANGE
* removing `onChange`
FEATURE
* adding three events: $beforeRouteChange, $afterRouteChange, $routeReload
Diffstat (limited to 'test/service/routeParamsSpec.js')
| -rw-r--r-- | test/service/routeParamsSpec.js | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/test/service/routeParamsSpec.js b/test/service/routeParamsSpec.js new file mode 100644 index 00000000..58a37f2e --- /dev/null +++ b/test/service/routeParamsSpec.js @@ -0,0 +1,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); + }); +}); |
