aboutsummaryrefslogtreecommitdiffstats
path: root/test/ngRoute/routeParamsSpec.js
diff options
context:
space:
mode:
authorjoshrtay2012-12-26 21:45:11 -0800
committerJames deBoer2013-08-12 11:04:37 -0700
commit04cebcc133c8b433a3ac5f72ed19f3631778142b (patch)
tree17c7307558e2c41624d1092a7e826a20967112ee /test/ngRoute/routeParamsSpec.js
parentc173ca412878d537b18df01f39e400ea48a4b398 (diff)
downloadangular.js-04cebcc133c8b433a3ac5f72ed19f3631778142b.tar.bz2
feat($route): express style route matching
Added new route matching capabilities: - optional param Changed route matching syntax: - named wildcard BREAKING CHANGE: the syntax for named wildcard parameters in routes has changed from *wildcard to :wildcard* To migrate the code, follow the example below. Here, *highlight becomes :highlight*: Before: $routeProvider.when('/Book1/:book/Chapter/:chapter/*highlight/edit', {controller: noop, templateUrl: 'Chapter.html'}); After: $routeProvider.when('/Book1/:book/Chapter/:chapter/:highlight*/edit', {controller: noop, templateUrl: 'Chapter.html'});
Diffstat (limited to 'test/ngRoute/routeParamsSpec.js')
-rw-r--r--test/ngRoute/routeParamsSpec.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/ngRoute/routeParamsSpec.js b/test/ngRoute/routeParamsSpec.js
index 1391151c..7c10a922 100644
--- a/test/ngRoute/routeParamsSpec.js
+++ b/test/ngRoute/routeParamsSpec.js
@@ -45,4 +45,37 @@ describe('$routeParams', function() {
expect($routeParams).toEqual({barId: 'barvalue', fooId: 'foovalue'});
});
});
+
+ it('should correctly extract the params when an optional param name is part of the route', function() {
+ module(function($routeProvider) {
+ $routeProvider.when('/bar/:foo?', {});
+ $routeProvider.when('/baz/:foo?/edit', {});
+ $routeProvider.when('/qux/:bar?/:baz?', {});
+ });
+
+ inject(function($rootScope, $route, $location, $routeParams) {
+ $location.path('/bar');
+ $rootScope.$digest();
+ expect($routeParams).toEqual({});
+
+ $location.path('/bar/fooValue');
+ $rootScope.$digest();
+ expect($routeParams).toEqual({foo: 'fooValue'});
+
+ $location.path('/baz/fooValue/edit');
+ $rootScope.$digest();
+ expect($routeParams).toEqual({foo: 'fooValue'});
+
+ $location.path('/baz/edit');
+ $rootScope.$digest();
+ expect($routeParams).toEqual({});
+
+ $location.path('/qux//bazValue');
+ $rootScope.$digest();
+ expect($routeParams).toEqual({baz: 'bazValue', bar: undefined});
+
+ });
+ });
+
+
});