@@ -37,7 +37,10 @@ describe('state', function () {
37
37
ISS2101 = { params : { bar : { squash : false , value : 'qux' } } , url : '/2101/{bar:string}' } ;
38
38
AppInjectable = { } ;
39
39
40
- beforeEach ( module ( function ( $stateProvider , $provide ) {
40
+ beforeEach ( module ( function ( $stateProvider , $provide , $exceptionHandlerProvider ) {
41
+ var x = this ;
42
+ var foo = jasmine ;
43
+ $exceptionHandlerProvider . mode ( 'log' )
41
44
angular . forEach ( [ A , B , C , D , DD , E , H , HH , HHH ] , function ( state ) {
42
45
state . onEnter = callbackLogger ( 'onEnter' ) ;
43
46
state . onExit = callbackLogger ( 'onExit' ) ;
@@ -120,11 +123,6 @@ describe('state', function () {
120
123
} ,
121
124
controller : function ( ) { log += "controller;" }
122
125
} )
123
- . state ( 'onEnterFail' , {
124
- onEnter : function ( ) {
125
- throw new Error ( 'negative onEnter' ) ;
126
- }
127
- } )
128
126
. state ( 'badParam' , {
129
127
url : "/bad/{param:int}"
130
128
} )
@@ -556,20 +554,6 @@ describe('state', function () {
556
554
'A.onEnter;' ) ;
557
555
} ) ) ;
558
556
559
- it ( 'sends $stateChangeError for exceptions in onEnter' , inject ( function ( $state , $q , $rootScope ) {
560
- var called ;
561
- $rootScope . $on ( '$stateChangeError' , function ( ev , to , toParams , from , fromParams , options ) {
562
- called = true ;
563
- } ) ;
564
-
565
- initStateTo ( A ) ;
566
- $state . transitionTo ( 'onEnterFail' ) ;
567
- $q . flush ( ) ;
568
-
569
- expect ( called ) . toBeTruthy ( ) ;
570
- expect ( $state . current . name ) . toEqual ( A . name ) ;
571
- } ) ) ;
572
-
573
557
it ( 'doesn\'t transition to parent state when child has no URL' , inject ( function ( $state , $q ) {
574
558
$state . transitionTo ( 'about.sidebar' ) ; $q . flush ( ) ;
575
559
expect ( $state . current . name ) . toEqual ( 'about.sidebar' ) ;
@@ -1063,7 +1047,6 @@ describe('state', function () {
1063
1047
'logA' ,
1064
1048
'logA.logB' ,
1065
1049
'logA.logB.logC' ,
1066
- 'onEnterFail' ,
1067
1050
'resolveFail' ,
1068
1051
'resolveTimeout' ,
1069
1052
'root' ,
@@ -1670,6 +1653,35 @@ describe('state queue', function(){
1670
1653
} ) ;
1671
1654
} ) ;
1672
1655
1656
+ describe ( 'exceptions in onEnter' , function ( ) {
1657
+ beforeEach ( module ( function ( $stateProvider , $exceptionHandlerProvider ) {
1658
+ $exceptionHandlerProvider . mode ( 'log' ) ;
1659
+ $stateProvider
1660
+ . state ( 'A' , { } )
1661
+ . state ( 'onEnterFail' , {
1662
+ onEnter : function ( ) {
1663
+ throw new Error ( 'negative onEnter' ) ;
1664
+ }
1665
+ } ) ;
1666
+ } ) ) ;
1667
+
1668
+ it ( 'sends $stateChangeError for exceptions in onEnter' , inject ( function ( $state , $q , $rootScope ) {
1669
+ var called ;
1670
+ $rootScope . $on ( '$stateChangeError' , function ( ev , to , toParams , from , fromParams , options ) {
1671
+ called = true ;
1672
+ } ) ;
1673
+
1674
+ $state . go ( 'A' ) ; $q . flush ( ) ;
1675
+ expect ( $state . current . name ) . toEqual ( 'A' ) ;
1676
+
1677
+ $state . transitionTo ( 'onEnterFail' ) ;
1678
+ $q . flush ( ) ;
1679
+
1680
+ expect ( called ) . toBeTruthy ( ) ;
1681
+ expect ( $state . current . name ) . toEqual ( 'A' ) ;
1682
+ } ) )
1683
+ } ) ;
1684
+
1673
1685
describe ( '$stateParams' , function ( ) {
1674
1686
beforeEach ( module ( 'ui.router.state' ) ) ;
1675
1687
0 commit comments