@@ -91,6 +91,9 @@ describe('state', function () {
91
91
}
92
92
}
93
93
} )
94
+ . state ( 'badParam' , {
95
+ url : "/bad/{param:int}"
96
+ } )
94
97
95
98
. state ( 'first' , { url : '^/first/subpath' } )
96
99
. state ( 'second' , { url : '^/second' } )
@@ -712,6 +715,7 @@ describe('state', function () {
712
715
'about.person.item' ,
713
716
'about.sidebar' ,
714
717
'about.sidebar.item' ,
718
+ 'badParam' ,
715
719
'dynamicController' ,
716
720
'first' ,
717
721
'home' ,
@@ -779,6 +783,29 @@ describe('state', function () {
779
783
expect ( $state . current . name ) . toBe ( '' ) ;
780
784
} ) ) ;
781
785
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
+
782
809
it ( 'should revert to last known working url on state change failure' , inject ( function ( $state , $rootScope , $location , $q ) {
783
810
$state . transitionTo ( "about" ) ;
784
811
$q . flush ( ) ;
0 commit comments