@@ -162,18 +162,18 @@ describe('HookBuilder:', function() {
162
162
Object . keys ( $trans . _deregisterHookFns ) . forEach ( key => $trans . _deregisterHookFns [ key ] ( ) ) ;
163
163
} ) ;
164
164
165
- describe ( 'should be bound to the correct context' , function ( ) {
165
+ describe ( 'should have the correct state context' , function ( ) {
166
166
const context = hook =>
167
- tail ( hook . resolveContext [ '_path' ] ) . state . name ;
167
+ hook . stateContext && hook . stateContext . name ;
168
168
169
- it ( '; onBefore should be bound to the to state' , function ( ) {
169
+ it ( '; onBefore should not have a state context ' , function ( ) {
170
170
trans . onBefore ( { } , callback ) ;
171
- expect ( hb . getOnBeforeHooks ( ) . map ( context ) ) . toEqual ( [ "A.B.C" ] ) ;
171
+ expect ( hb . getOnBeforeHooks ( ) . map ( context ) ) . toEqual ( [ null ] ) ;
172
172
} ) ;
173
173
174
- it ( '; onStart should be bound to the to state' , function ( ) {
174
+ it ( '; onStart should not have a state context ' , function ( ) {
175
175
trans . onStart ( { } , callback ) ;
176
- expect ( hb . getOnStartHooks ( ) . map ( context ) ) . toEqual ( [ "A.B.C" ] ) ;
176
+ expect ( hb . getOnStartHooks ( ) . map ( context ) ) . toEqual ( [ null ] ) ;
177
177
} ) ;
178
178
179
179
it ( '; onEnter should be bound to the entering state(s)' , function ( ) {
@@ -186,30 +186,25 @@ describe('HookBuilder:', function() {
186
186
expect ( hb . getOnRetainHooks ( ) . map ( context ) ) . toEqual ( [ "" , "A" ] ) ;
187
187
} ) ;
188
188
189
- it ( '; onRetain should be bound to the retained state(s)' , function ( ) {
190
- trans . onRetain ( { } , callback ) ;
191
- expect ( hb . getOnRetainHooks ( ) . map ( context ) ) . toEqual ( [ "" , "A" ] ) ;
192
- } ) ;
193
-
194
189
it ( '; onExit should be bound to the exiting state(s)' , function ( ) {
195
190
trans2 . onExit ( { } , callback ) ;
196
191
expect ( hb2 . getOnExitHooks ( ) . map ( context ) ) . toEqual ( [ "A.B.C" , "A.B" ] ) ;
197
192
} ) ;
198
193
199
- it ( '; onFinish should be bound to the to state' , function ( ) {
194
+ it ( '; onFinish should not have a state context ' , function ( ) {
200
195
trans . onFinish ( { } , callback ) ;
201
- expect ( hb . getOnFinishHooks ( ) . map ( context ) ) . toEqual ( [ "A.B.C" ] ) ;
196
+ expect ( hb . getOnFinishHooks ( ) . map ( context ) ) . toEqual ( [ null ] ) ;
202
197
} ) ;
203
198
204
- it ( '; onSuccess should be bound to the to state' , function ( ) {
199
+ it ( '; onSuccess should not have a state context ' , function ( ) {
205
200
trans . onSuccess ( { } , callback ) ;
206
- expect ( hb . getOnSuccessHooks ( ) . map ( context ) ) . toEqual ( [ "A.B.C" ] ) ;
201
+ expect ( hb . getOnSuccessHooks ( ) . map ( context ) ) . toEqual ( [ null ] ) ;
207
202
} ) ;
208
203
209
- it ( '; onError should be bound to the to state' , function ( ) {
204
+ it ( '; onError should not have a state context ' , function ( ) {
210
205
trans . onStart ( { } , ( ) => { throw new Error ( 'shuckydarn' ) } ) ;
211
206
trans . onError ( { } , callback ) ;
212
- expect ( hb . getOnErrorHooks ( ) . map ( context ) ) . toEqual ( [ "A.B.C" ] ) ;
207
+ expect ( hb . getOnErrorHooks ( ) . map ( context ) ) . toEqual ( [ null ] ) ;
213
208
} ) ;
214
209
215
210
} ) ;
0 commit comments