@@ -91,6 +91,9 @@ describe('state', function () {
9191 }
9292 }
9393 } )
94+ . state ( 'badParam' , {
95+ url : "/bad/{param:int}"
96+ } )
9497
9598 . state ( 'first' , { url : '^/first/subpath' } )
9699 . state ( 'second' , { url : '^/second' } )
@@ -712,6 +715,7 @@ describe('state', function () {
712715 'about.person.item' ,
713716 'about.sidebar' ,
714717 'about.sidebar.item' ,
718+ 'badParam' ,
715719 'dynamicController' ,
716720 'first' ,
717721 'home' ,
@@ -779,6 +783,29 @@ describe('state', function () {
779783 expect ( $state . current . name ) . toBe ( '' ) ;
780784 } ) ) ;
781785
786+ describe ( "typed parameter handling" , function ( ) {
787+
788+ it ( 'should initialize parameters without a hacky empty test' , inject ( function ( $urlMatcherFactory , $state ) {
789+ new UrlMatcher ( "" ) ;
790+ } ) ) ;
791+
792+ it ( 'should ignore bad url parameters' , inject ( function ( $state , $rootScope , $location , $urlMatcherFactory ) {
793+ $location . path ( "/bad/5" ) ;
794+ $rootScope . $broadcast ( "$locationChangeSuccess" ) ;
795+ $rootScope . $apply ( ) ;
796+ expect ( $state . current . name ) . toBe ( "badParam" ) ;
797+
798+ $state . transitionTo ( "about" ) ;
799+ $rootScope . $apply ( ) ;
800+ expect ( $state . current . name ) . toBe ( 'about' ) ;
801+
802+ $location . path ( "/bad/foo" ) ;
803+ $rootScope . $broadcast ( "$locationChangeSuccess" ) ;
804+ $rootScope . $apply ( ) ;
805+ expect ( $state . current . name ) . toBe ( "about" ) ;
806+ } ) ) ;
807+ } ) ;
808+
782809 it ( 'should revert to last known working url on state change failure' , inject ( function ( $state , $rootScope , $location , $q ) {
783810 $state . transitionTo ( "about" ) ;
784811 $q . flush ( ) ;
0 commit comments