@@ -53,6 +53,46 @@ describe('Router', function () {
53
53
done ( ) ;
54
54
} ) ;
55
55
} ) ;
56
+
57
+ it ( 'execute willTransition* callbacks when query changes' , function ( done ) {
58
+ var fromCallbackExecuted = false ;
59
+ var Spoon = React . createClass ( {
60
+ statics : {
61
+ willTransitionTo : function ( transition , params , query ) {
62
+ if ( query [ 'filter' ] === 'first' ) {
63
+ return ; // skip first transition
64
+ }
65
+
66
+ expect ( query [ 'filter' ] ) . toEqual ( 'second' ) ;
67
+ expect ( fromCallbackExecuted ) . toBe ( true ) ;
68
+ done ( ) ;
69
+ } ,
70
+
71
+ willTransitionFrom : function ( transition , element ) {
72
+ fromCallbackExecuted = true ;
73
+ }
74
+ } ,
75
+
76
+ render : function ( ) {
77
+ return < h1 > Spoon</ h1 > ;
78
+ }
79
+ } ) ;
80
+
81
+ var routes = (
82
+ < Route handler = { Nested } path = '/' >
83
+ < Route name = "spoon" handler = { Spoon } />
84
+ </ Route >
85
+ ) ;
86
+
87
+ TestLocation . history = [ '/spoon?filter=first' ] ;
88
+
89
+ var div = document . createElement ( 'div' ) ;
90
+ Router . run ( routes , TestLocation , function ( Handler , state ) {
91
+ React . render ( < Handler /> , div ) ;
92
+ } ) ;
93
+
94
+ TestLocation . push ( '/spoon?filter=second' ) ;
95
+ } ) ;
56
96
} ) ;
57
97
58
98
describe ( 'willTransitionFrom' , function ( ) {
@@ -87,7 +127,6 @@ describe('Router', function () {
87
127
} ) ;
88
128
} ) ;
89
129
} ) ;
90
-
91
130
} ) ;
92
131
93
132
} ) ;
0 commit comments