@@ -331,6 +331,50 @@ describe('$route', function() {
331331 } ) ;
332332
333333
334+ it ( 'should skip routes with incomplete params' , function ( ) {
335+ module ( function ( $routeProvider ) {
336+ $routeProvider
337+ . otherwise ( { template : 'other' } )
338+ . when ( '/pages/:page/:comment*' , { template : 'comment' } )
339+ . when ( '/pages/:page' , { template : 'page' } )
340+ . when ( '/pages' , { template : 'index' } )
341+ . when ( '/foo/' , { template : 'foo' } )
342+ . when ( '/foo/:bar' , { template : 'bar' } )
343+ . when ( '/foo/:bar*/:baz' , { template : 'baz' } ) ;
344+ } ) ;
345+
346+ inject ( function ( $route , $location , $rootScope ) {
347+ $location . url ( '/pages/' ) ;
348+ $rootScope . $digest ( ) ;
349+ expect ( $route . current . template ) . toBe ( 'index' ) ;
350+
351+ $location . url ( '/pages/page/' ) ;
352+ $rootScope . $digest ( ) ;
353+ expect ( $route . current . template ) . toBe ( 'page' ) ;
354+
355+ $location . url ( '/pages/page/1/' ) ;
356+ $rootScope . $digest ( ) ;
357+ expect ( $route . current . template ) . toBe ( 'comment' ) ;
358+
359+ $location . url ( '/foo/' ) ;
360+ $rootScope . $digest ( ) ;
361+ expect ( $route . current . template ) . toBe ( 'foo' ) ;
362+
363+ $location . url ( '/foo/bar/' ) ;
364+ $rootScope . $digest ( ) ;
365+ expect ( $route . current . template ) . toBe ( 'bar' ) ;
366+
367+ $location . url ( '/foo/bar/baz/' ) ;
368+ $rootScope . $digest ( ) ;
369+ expect ( $route . current . template ) . toBe ( 'baz' ) ;
370+
371+ $location . url ( '/something/' ) ;
372+ $rootScope . $digest ( ) ;
373+ expect ( $route . current . template ) . toBe ( 'other' ) ;
374+ } ) ;
375+ } ) ;
376+
377+
334378 describe ( 'otherwise' , function ( ) {
335379
336380 it ( 'should handle unknown routes with "otherwise" route definition' , function ( ) {
0 commit comments