aboutsummaryrefslogtreecommitdiffstats
path: root/test/ng
diff options
context:
space:
mode:
authorMartin Probst2013-01-14 20:01:51 +0100
committerIgor Minar2013-01-16 09:42:35 -0800
commitd575e1f613642953fde2d7fdd7123d48f526d42a (patch)
tree4095baf80fbc2c58af2e0fad88a85b8ecf72b661 /test/ng
parent2ba458387d19543b45c3bfdbe8db719d2c0f1f15 (diff)
downloadangular.js-d575e1f613642953fde2d7fdd7123d48f526d42a.tar.bz2
fix($route): support route params not separated with slashes.
Commit 773ac4a broke support for route parameters that are not seperated from other route parts by slashes, which this change fixes. It also adds some documentation about path parameters to the when() method and escapes all regular expression special characters in the URL, not just some.
Diffstat (limited to 'test/ng')
-rw-r--r--test/ng/routeParamsSpec.js12
-rw-r--r--test/ng/routeSpec.js32
2 files changed, 34 insertions, 10 deletions
diff --git a/test/ng/routeParamsSpec.js b/test/ng/routeParamsSpec.js
index 07c6d4f7..52fe8d2a 100644
--- a/test/ng/routeParamsSpec.js
+++ b/test/ng/routeParamsSpec.js
@@ -29,4 +29,16 @@ describe('$routeParams', function() {
expect($routeParams).toEqual({bar:'barvalue', foo:'foovalue'});
});
});
+
+ it('should support route params not preceded by slashes', function() {
+ module(function($routeProvider) {
+ $routeProvider.when('/bar:barId/foo:fooId/', {});
+ });
+
+ inject(function($rootScope, $route, $location, $routeParams) {
+ $location.path('/barbarvalue/foofoovalue/');
+ $rootScope.$digest();
+ expect($routeParams).toEqual({barId: 'barvalue', fooId: 'foovalue'});
+ });
+ });
});
diff --git a/test/ng/routeSpec.js b/test/ng/routeSpec.js
index 52fffa40..852f97b5 100644
--- a/test/ng/routeSpec.js
+++ b/test/ng/routeSpec.js
@@ -82,28 +82,40 @@ describe('$route', function() {
});
- it('should match a route that contains special chars in the path', function() {
- module(function($routeProvider) {
- $routeProvider.when('/$test.23/foo(bar)/:baz', {templateUrl: 'test.html'});
- });
- inject(function($route, $location, $rootScope) {
+ describe('should match a route that contains special chars in the path', function() {
+ beforeEach(module(function($routeProvider) {
+ $routeProvider.when('/$test.23/foo*(bar)/:baz', {templateUrl: 'test.html'});
+ }));
+ it('matches the full path', inject(function($route, $location, $rootScope) {
$location.path('/test');
$rootScope.$digest();
expect($route.current).toBeUndefined();
+ }));
- $location.path('/$testX23/foo(bar)/222');
+ it('matches literal .', inject(function($route, $location, $rootScope) {
+ $location.path('/$testX23/foo*(bar)/222');
$rootScope.$digest();
expect($route.current).toBeUndefined();
+ }));
- $location.path('/$test.23/foo(bar)/222');
+ it('matches literal *', inject(function($route, $location, $rootScope) {
+ $location.path('/$test.23/foooo(bar)/222');
$rootScope.$digest();
- expect($route.current).toBeDefined();
+ expect($route.current).toBeUndefined();
+ }));
- $location.path('/$test.23/foo\\(bar)/222');
+ it('treats backslashes normally', inject(function($route, $location, $rootScope) {
+ $location.path('/$test.23/foo*\\(bar)/222');
$rootScope.$digest();
expect($route.current).toBeUndefined();
- });
+ }));
+
+ it('matches a URL with special chars', inject(function($route, $location, $rootScope) {
+ $location.path('/$test.23/foo*(bar)/222');
+ $rootScope.$digest();
+ expect($route.current).toBeDefined();
+ }));
});