@@ -14,16 +14,18 @@ import {Transition} from "../../src/transition/transition";
14
14
15
15
describe ( 'transition' , function ( ) {
16
16
17
- var transitionProvider , matcher , pathFactory , statesMap , queue ;
17
+ var $exceptionHandler , transitionProvider , matcher , pathFactory , statesMap , queue ;
18
18
19
19
var targetState = function ( identifier , params = { } , options ?) {
20
20
options = options || { } ;
21
21
var stateDefinition = matcher . find ( identifier , options . relative ) ;
22
22
return new TargetState ( identifier , stateDefinition , params , options ) ;
23
23
} ;
24
24
25
- beforeEach ( module ( 'ui.router' , function ( $transitionsProvider , $urlMatcherFactoryProvider ) {
25
+ beforeEach ( module ( 'ui.router' , function ( $transitionsProvider , $urlMatcherFactoryProvider , $exceptionHandlerProvider ) {
26
+ decorateExceptionHandler ( $exceptionHandlerProvider ) ;
26
27
transitionProvider = $transitionsProvider ;
28
+
27
29
var stateTree = {
28
30
first : { } ,
29
31
second : { } ,
@@ -71,7 +73,8 @@ describe('transition', function () {
71
73
72
74
var makeTransition ;
73
75
74
- beforeEach ( inject ( function ( $transitions , $state ) {
76
+ beforeEach ( inject ( function ( $transitions , $state , _$exceptionHandler_ ) {
77
+ $exceptionHandler = _$exceptionHandler_ ;
75
78
matcher = new StateMatcher ( statesMap ) ;
76
79
queue . flush ( $state ) ;
77
80
makeTransition = function makeTransition ( from , to , options ) {
@@ -113,6 +116,7 @@ describe('transition', function () {
113
116
114
117
it ( '$transition$.promise should reject on error' , inject ( function ( $transitions , $q ) {
115
118
var result = new PromiseResult ( ) ;
119
+ $exceptionHandler . disabled = true ;
116
120
117
121
transitionProvider . onStart ( { from : "*" , to : "third" } , function ( $transition$ ) {
118
122
result . setPromise ( $transition$ . promise ) ;
@@ -126,6 +130,7 @@ describe('transition', function () {
126
130
127
131
it ( '$transition$.promise should reject on error in synchronous hooks' , inject ( function ( $transitions , $q ) {
128
132
var result = new PromiseResult ( ) ;
133
+ $exceptionHandler . disabled = true ;
129
134
130
135
transitionProvider . onBefore ( { from : "*" , to : "third" } , function ( $transition$ ) {
131
136
result . setPromise ( $transition$ . promise ) ;
@@ -298,6 +303,7 @@ describe('transition', function () {
298
303
} ) ) ;
299
304
300
305
it ( 'should be called even if other .onSuccess() callbacks fail (throw errors, etc)' , inject ( function ( $transitions , $q ) {
306
+ $exceptionHandler . disabled = true ;
301
307
transitionProvider . onSuccess ( { from : "*" , to : "*" } , function ( ) { throw new Error ( "oops!" ) ; } ) ;
302
308
transitionProvider . onSuccess ( { from : "*" , to : "*" } , function ( trans ) { states . push ( trans . to ( ) . name ) ; } ) ;
303
309
@@ -318,6 +324,7 @@ describe('transition', function () {
318
324
} ) ) ;
319
325
320
326
it ( 'should be called if any part of the transition fails.' , inject ( function ( $transitions , $q ) {
327
+ $exceptionHandler . disabled = true ;
321
328
transitionProvider . onEnter ( { from : "A" , entering : "C" } , function ( ) { throw new Error ( "oops!" ) ; } ) ;
322
329
transitionProvider . onError ( { } , function ( trans ) { states . push ( trans . to ( ) . name ) ; } ) ;
323
330
@@ -327,6 +334,7 @@ describe('transition', function () {
327
334
} ) ) ;
328
335
329
336
it ( 'should be called for only handlers matching the transition.' , inject ( function ( $transitions , $q ) {
337
+ $exceptionHandler . disabled = true ;
330
338
transitionProvider . onEnter ( { from : "A" , entering : "C" } , function ( ) { throw new Error ( "oops!" ) ; } ) ;
331
339
transitionProvider . onError ( { from : "*" , to : "*" } , function ( ) { hooks . push ( "splatsplat" ) ; } ) ;
332
340
transitionProvider . onError ( { from : "A" , to : "C" } , function ( ) { hooks . push ( "AC" ) ; } ) ;
0 commit comments