File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -129,6 +129,29 @@ describe('transition', function () {
129129 . then ( done ) ;
130130 } ) ) ;
131131
132+ // Test for #2972 and https://github.com/ui-router/react/issues/3
133+ it ( 'should reject transitions that are superseded by a new transition' , ( ( done ) => {
134+ $state . defaultErrorHandler ( function ( ) { } ) ;
135+ router . stateRegistry . register ( {
136+ name : 'slowResolve' ,
137+ resolve : {
138+ foo : ( ) => new Promise ( resolve => setTimeout ( resolve , 50 ) )
139+ }
140+ } ) ;
141+
142+ let results = { success : 0 , error : 0 } ;
143+ let success = ( ) => results . success ++ ;
144+ let error = ( ) => results . error ++ ;
145+ $transitions . onBefore ( { } , trans => { trans . promise . then ( success , error ) } ) ;
146+
147+ $state . go ( 'slowResolve' ) ;
148+
149+ setTimeout ( ( ) => $state . go ( 'slowResolve' ) . transition . promise . then ( ( ) => {
150+ expect ( results ) . toEqual ( { success : 1 , error : 1 } ) ;
151+ done ( ) ;
152+ } ) , 20 ) ;
153+ } ) ) ;
154+
132155 describe ( '.onStart()' , function ( ) {
133156 it ( 'should fire matching events when transition starts' , ( ( done ) => {
134157 var t = null ;
You can’t perform that action at this time.
0 commit comments