aboutsummaryrefslogtreecommitdiffstats
path: root/test/ngRoute/routeParamsSpec.js
diff options
context:
space:
mode:
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});
+
+ });
+ });
+
+
});