@@ -273,21 +273,11 @@ describe('matchHeight', function() {
273
273
} ) ;
274
274
275
275
it ( 'can manually update heights and fires global callbacks' , function ( done ) {
276
- var currentBreakpoint = testHelper . getCurrentBreakpoint ( ) ,
277
- calledBefore = false ,
278
- calledAfter = false ;
276
+ var currentBreakpoint = testHelper . getCurrentBreakpoint ( ) ;
279
277
280
- var oldBefore = $ . fn . matchHeight . _beforeUpdate ,
281
- oldAfter = $ . fn . matchHeight . _afterUpdate ;
282
-
283
- // set some test update callbacks
284
- $ . fn . matchHeight . _beforeUpdate = function ( ) {
285
- calledBefore = true ;
286
- } ;
287
-
288
- $ . fn . matchHeight . _afterUpdate = function ( ) {
289
- calledAfter = true ;
290
- } ;
278
+ // spy on global callbacks
279
+ spyOn ( $ . fn . matchHeight , '_beforeUpdate' ) ;
280
+ spyOn ( $ . fn . matchHeight , '_afterUpdate' ) ;
291
281
292
282
// add more content to one of the items to change it's height
293
283
$ ( '.simple-items .item-1' ) . append ( '<p>Test content update.</p>' ) ;
@@ -329,12 +319,15 @@ describe('matchHeight', function() {
329
319
}
330
320
331
321
// check callbacks were fired
332
- expect ( calledBefore ) . toBe ( true ) ;
333
- expect ( calledAfter ) . toBe ( true ) ;
322
+ expect ( $ . fn . matchHeight . _beforeUpdate ) . toHaveBeenCalled ( ) ;
323
+ expect ( $ . fn . matchHeight . _afterUpdate ) . toHaveBeenCalled ( ) ;
324
+
325
+ var beforeUpdateArgs = $ . fn . matchHeight . _beforeUpdate . calls . argsFor ( 0 ) ,
326
+ afterUpdateArgs = $ . fn . matchHeight . _afterUpdate . calls . argsFor ( 0 ) ;
334
327
335
- // revert callbacks
336
- $ . fn . matchHeight . _beforeUpdate = oldBefore ;
337
- $ . fn . matchHeight . _afterUpdate = oldAfter ;
328
+ // group arg
329
+ expect ( $ . isArray ( beforeUpdateArgs [ 1 ] ) ) . toBe ( true ) ;
330
+ expect ( $ . isArray ( afterUpdateArgs [ 1 ] ) ) . toBe ( true ) ;
338
331
339
332
done ( ) ;
340
333
} ) ;
0 commit comments