@@ -532,6 +532,46 @@ describe('Router', function () {
532
532
done ( ) ;
533
533
} ) ;
534
534
} ) ;
535
+
536
+ it ( 'execute willTransition* callbacks when query changes' , function ( done ) {
537
+ var fromCallbackExecuted = false ;
538
+ var Spoon = React . createClass ( {
539
+ statics : {
540
+ willTransitionTo : function ( transition , params , query ) {
541
+ if ( query [ 'filter' ] === 'first' ) {
542
+ return ; // skip first transition
543
+ }
544
+
545
+ expect ( query [ 'filter' ] ) . toEqual ( 'second' ) ;
546
+ expect ( fromCallbackExecuted ) . toBe ( true ) ;
547
+ done ( ) ;
548
+ } ,
549
+
550
+ willTransitionFrom : function ( transition , element ) {
551
+ fromCallbackExecuted = true ;
552
+ }
553
+ } ,
554
+
555
+ render : function ( ) {
556
+ return < h1 > Spoon</ h1 > ;
557
+ }
558
+ } ) ;
559
+
560
+ var routes = (
561
+ < Route handler = { Nested } path = '/' >
562
+ < Route name = "spoon" handler = { Spoon } />
563
+ </ Route >
564
+ ) ;
565
+
566
+ TestLocation . history = [ '/spoon?filter=first' ] ;
567
+
568
+ var div = document . createElement ( 'div' ) ;
569
+ Router . run ( routes , TestLocation , function ( Handler , state ) {
570
+ React . render ( < Handler /> , div ) ;
571
+ } ) ;
572
+
573
+ TestLocation . push ( '/spoon?filter=second' ) ;
574
+ } ) ;
535
575
} ) ;
536
576
537
577
describe ( 'willTransitionFrom' , function ( ) {
@@ -566,7 +606,6 @@ describe('Router', function () {
566
606
} ) ;
567
607
} ) ;
568
608
} ) ;
569
-
570
609
} ) ;
571
610
572
611
} ) ;
0 commit comments