@@ -31,6 +31,30 @@ describe('stickyState', function () {
31
31
return newStates ;
32
32
}
33
33
34
+ function getNestedStickyStates ( ) {
35
+ var newStates = { } ;
36
+ newStates [ 'aside' ] = { } ;
37
+ newStates [ 'A' ] = { sticky : true , deepStateRedirect : true , views : { 'A@' : { } } } ;
38
+
39
+ newStates [ 'A._1' ] = { sticky : true , deepStateRedirect : true , views : { '_1@A' : { } } } ;
40
+ newStates [ 'A._2' ] = { sticky : true , deepStateRedirect : true , views : { '_2@A' : { } } } ;
41
+ newStates [ 'A._3' ] = { sticky : true , views : { '_3@A' : { } } } ;
42
+
43
+ newStates [ 'A._1.__1' ] = { } ;
44
+ newStates [ 'A._1.__2' ] = { } ;
45
+ newStates [ 'A._2.__1' ] = { } ;
46
+ newStates [ 'A._2.__2' ] = { } ;
47
+ newStates [ 'A._3.__1' ] = { views : { '__1@A._3' : { } } } ;
48
+ newStates [ 'A._3.__2' ] = { views : { '__2@A._3' : { } } } ;
49
+
50
+ newStates [ 'A._1.__1.B' ] = { } ;
51
+ newStates [ 'A._1.__1.B.___1' ] = { sticky : true , views : { '___1@A._1.__1.B' : { } } } ;
52
+ newStates [ 'A._1.__1.B.___2' ] = { sticky : true , views : { '___2@A._1.__1.B' : { } } } ;
53
+ newStates [ 'A._1.__1.B.___3' ] = { sticky : true , views : { '___3@A._1.__1.B' : { } } } ;
54
+
55
+ return newStates ;
56
+ }
57
+
34
58
beforeEach ( module ( 'ct.ui.router.extras.sticky' , function ( $stateProvider , $stickyStateProvider ) {
35
59
_stateProvider = $stateProvider ;
36
60
_stickyStateProvider = $stickyStateProvider ;
@@ -273,28 +297,6 @@ describe('stickyState', function () {
273
297
ssReset ( getNestedStickyStates ( ) , _stateProvider ) ;
274
298
} ) ;
275
299
276
- function getNestedStickyStates ( ) {
277
- var newStates = { } ;
278
- newStates [ 'aside' ] = { } ;
279
- newStates [ 'A' ] = { sticky : true , deepStateRedirect : true , views : { 'A@' : { } } } ;
280
-
281
- newStates [ 'A._1' ] = { sticky : true , deepStateRedirect : true , views : { '_1@A' : { } } } ;
282
- newStates [ 'A._2' ] = { sticky : true , deepStateRedirect : true , views : { '_2@A' : { } } } ;
283
- newStates [ 'A._3' ] = { sticky : true , views : { '_3@A' : { } } } ;
284
-
285
- newStates [ 'A._1.__1' ] = { } ;
286
- newStates [ 'A._2.__2' ] = { } ;
287
- newStates [ 'A._3.__1' ] = { views : { '__1@A._3' : { } } } ;
288
- newStates [ 'A._3.__2' ] = { views : { '__2@A._3' : { } } } ;
289
-
290
- newStates [ 'A._1.__1.B' ] = { } ;
291
- newStates [ 'A._1.__1.B.___1' ] = { sticky : true , views : { '___1@A._1.__1.B' : { } } } ;
292
- newStates [ 'A._1.__1.B.___2' ] = { sticky : true , views : { '___2@A._1.__1.B' : { } } } ;
293
- newStates [ 'A._1.__1.B.___3' ] = { sticky : true , views : { '___3@A._1.__1.B' : { } } } ;
294
-
295
- return newStates ;
296
- }
297
-
298
300
it ( 'should inactivate sticky state tabs_tab1 when transitioning back to A' , function ( ) {
299
301
testGo ( 'aside' , { entered : [ 'aside' ] } ) ;
300
302
testGo ( 'A._1.__1.B.___1' , { exited : [ 'aside' ] , entered : pathFrom ( 'A' , 'A._1.__1.B.___1' ) } ) ;
@@ -325,7 +327,7 @@ describe('stickyState', function () {
325
327
it ( "should not exit inactive child states" , function ( ) {
326
328
testGo ( 'A._3.__1' , { entered : pathFrom ( 'A' , 'A._3.__1' ) } ) ;
327
329
testGo ( 'A._2' , { inactivated : pathFrom ( 'A._3.__1' , 'A._3' ) , entered : "A._2" } ) ;
328
- testGo ( 'A._3.__2' , { reactivated : "A._3" , inactivated : "A._2" , entered : "A._3.__2" } ) ;
330
+ testGo ( 'A._3.__2' , { reactivated : "A._3" , inactivated : "A._2" , entered : "A._3.__2" , exited : "A._3.__1" } ) ;
329
331
} ) ;
330
332
} )
331
333
} ) ;
@@ -468,6 +470,36 @@ describe('stickyState', function () {
468
470
expect ( $stickyState . getInactiveStates ( ) . length ) . toBe ( 0 ) ;
469
471
} ) ;
470
472
} ) ;
473
+
474
+ describe ( "transitions to sibling of inactive state" , function ( ) {
475
+ // Tests for issue #217
476
+
477
+ beforeEach ( function ( ) {
478
+ ssReset ( getNestedStickyStates ( ) , _stateProvider ) ;
479
+ } ) ;
480
+
481
+ it ( "should exit the inactive state" , function ( ) {
482
+ testGo ( 'A._1.__1' , { entered : [ 'A' , 'A._1' , 'A._1.__1' ] } ) ;
483
+ testGo ( 'A._2.__1' , { entered : [ 'A._2' , 'A._2.__1' ] , inactivated : [ 'A._1.__1' , 'A._1' ] } ) ;
484
+ testGo ( 'A._1.__2' , {
485
+ entered : [ 'A._1.__2' ] ,
486
+ exited : [ 'A._1.__1' ] ,
487
+ reactivated : [ 'A._1' ] ,
488
+ inactivated : [ 'A._2.__1' , 'A._2' ]
489
+ } ) ;
490
+ } ) ;
491
+
492
+ it ( "should exit the inactive state tree" , function ( ) {
493
+ testGo ( 'A._1.__1.B' , { entered : [ 'A' , 'A._1' , 'A._1.__1' , 'A._1.__1.B' ] } ) ;
494
+ testGo ( 'A._2.__1' , { entered : [ 'A._2' , 'A._2.__1' ] , inactivated : [ 'A._1.__1.B' , 'A._1.__1' , 'A._1' ] } ) ;
495
+ testGo ( 'A._1.__2' , {
496
+ entered : [ 'A._1.__2' ] ,
497
+ exited : [ 'A._1.__1.B' , 'A._1.__1' ] ,
498
+ reactivated : [ 'A._1' ] ,
499
+ inactivated : [ 'A._2.__1' , 'A._2' ]
500
+ } ) ;
501
+ } ) ;
502
+ } )
471
503
} ) ;
472
504
473
505
describe ( 'stickyState+ui-sref-active' , function ( ) {
0 commit comments