Skip to content

Commit c7a0b41

Browse files
committed
test(ngRoute): add test case for special params in redirectUrl
Make sure that :name? and :name* vars are properly interpolated in redirectUrl.
1 parent 6f77610 commit c7a0b41

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

test/ngRoute/routeSpec.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,32 @@ describe('$route', function() {
813813
});
814814

815815

816+
it('should interpolate optional and long route vars in the redirected path from original path', function() {
817+
module(function($routeProvider) {
818+
$routeProvider.when('/foo/:id/foo/:subid?/:extraId', {redirectTo: '/bar/:id/:subid?/23'});
819+
$routeProvider.when('/baz/:id/:path*', {redirectTo: '/path/:path*/:id'});
820+
});
821+
822+
inject(function($route, $location, $rootScope) {
823+
$location.path('/foo/id1/foo/subid3/gah');
824+
$rootScope.$digest();
825+
826+
expect($location.path()).toEqual('/bar/id1/subid3/23');
827+
expect($location.search()).toEqual({extraId: 'gah'});
828+
829+
$location.path('/foo/id1/foo/gah');
830+
$rootScope.$digest();
831+
832+
expect($location.path()).toEqual('/bar/id1/23');
833+
expect($location.search()).toEqual({extraId: 'gah'});
834+
835+
$location.path('/baz/1/foovalue/barvalue');
836+
$rootScope.$digest();
837+
expect($location.path()).toEqual('/path/foovalue/barvalue/1');
838+
});
839+
});
840+
841+
816842
it('should interpolate route vars in the redirected path from original search', function() {
817843
module(function($routeProvider) {
818844
$routeProvider.when('/bar/:id/:subid/:subsubid', {templateUrl: 'bar.html'});

0 commit comments

Comments
 (0)