aboutsummaryrefslogtreecommitdiffstats
path: root/test/service/routeSpec.js
diff options
context:
space:
mode:
authorIgor Minar2012-03-20 00:38:08 -0700
committerIgor Minar2012-03-20 11:07:37 -0700
commita4fe51da3ba0dc297ecd389e230d6664f250c9a6 (patch)
tree68f86adad082bcf23d96c2b71d47a37060841a18 /test/service/routeSpec.js
parentee5a5352fd4b94cedee6ef20d4bf2d43ce77e00b (diff)
downloadangular.js-a4fe51da3ba0dc297ecd389e230d6664f250c9a6.tar.bz2
feat($route): when matching consider trailing slash as optional
This makes for a much more flexible route matching: - route /foo matches /foo and redirects /foo/ to /foo - route /bar/ matches /bar/ and redirects /bar to /bar/ Closes #784
Diffstat (limited to 'test/service/routeSpec.js')
-rw-r--r--test/service/routeSpec.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/service/routeSpec.js b/test/service/routeSpec.js
index 6b8127a0..88e54b9a 100644
--- a/test/service/routeSpec.js
+++ b/test/service/routeSpec.js
@@ -168,6 +168,36 @@ describe('$route', function() {
});
+ it('should match route with and without trailing slash', function() {
+ module(function($routeProvider){
+ $routeProvider.when('/foo', {template: 'foo.html'});
+ $routeProvider.when('/bar/', {template: 'bar.html'});
+ });
+
+ inject(function($route, $location, $rootScope) {
+ $location.path('/foo');
+ $rootScope.$digest();
+ expect($location.path()).toBe('/foo');
+ expect($route.current.template).toBe('foo.html');
+
+ $location.path('/foo/');
+ $rootScope.$digest();
+ expect($location.path()).toBe('/foo');
+ expect($route.current.template).toBe('foo.html');
+
+ $location.path('/bar');
+ $rootScope.$digest();
+ expect($location.path()).toBe('/bar/');
+ expect($route.current.template).toBe('bar.html');
+
+ $location.path('/bar/');
+ $rootScope.$digest();
+ expect($location.path()).toBe('/bar/');
+ expect($route.current.template).toBe('bar.html');
+ });
+ });
+
+
describe('redirection', function() {
it('should support redirection via redirectTo property by updating $location', function() {
module(function($routeProvider) {