diff options
| author | Nicola Peduzzi | 2013-08-06 17:35:48 +0200 |
|---|---|---|
| committer | Vojta Jina | 2013-10-04 08:45:47 -0700 |
| commit | 0ff86c323359fba1a60bacab178e3c68528f8e1f (patch) | |
| tree | fc5add8ccb65bf5f93d57eba9303aec7cdfb1535 /test | |
| parent | 31f190d4d53921d32253ba80d9ebe57d6c1de82b (diff) | |
| download | angular.js-0ff86c323359fba1a60bacab178e3c68528f8e1f.tar.bz2 | |
fix(routeProvider): parametrized routes do not match against locations that would not valorize each parameters.
Diffstat (limited to 'test')
| -rw-r--r-- | test/ngRoute/routeSpec.js | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/test/ngRoute/routeSpec.js b/test/ngRoute/routeSpec.js index ae9883a2..bd7966e1 100644 --- a/test/ngRoute/routeSpec.js +++ b/test/ngRoute/routeSpec.js @@ -331,6 +331,50 @@ describe('$route', function() { }); + it('should skip routes with incomplete params', function() { + module(function($routeProvider) { + $routeProvider + .otherwise({template: 'other'}) + .when('/pages/:page/:comment*', {template: 'comment'}) + .when('/pages/:page', {template: 'page'}) + .when('/pages', {template: 'index'}) + .when('/foo/', {template: 'foo'}) + .when('/foo/:bar', {template: 'bar'}) + .when('/foo/:bar*/:baz', {template: 'baz'}); + }); + + inject(function($route, $location, $rootScope) { + $location.url('/pages/'); + $rootScope.$digest(); + expect($route.current.template).toBe('index'); + + $location.url('/pages/page/'); + $rootScope.$digest(); + expect($route.current.template).toBe('page'); + + $location.url('/pages/page/1/'); + $rootScope.$digest(); + expect($route.current.template).toBe('comment'); + + $location.url('/foo/'); + $rootScope.$digest(); + expect($route.current.template).toBe('foo'); + + $location.url('/foo/bar/'); + $rootScope.$digest(); + expect($route.current.template).toBe('bar'); + + $location.url('/foo/bar/baz/'); + $rootScope.$digest(); + expect($route.current.template).toBe('baz'); + + $location.url('/something/'); + $rootScope.$digest(); + expect($route.current.template).toBe('other'); + }); + }); + + describe('otherwise', function() { it('should handle unknown routes with "otherwise" route definition', function() { |
