@@ -307,6 +307,32 @@ describe('animations', function() {
307
307
} ) ;
308
308
} ) ;
309
309
310
+ it ( 'should not try to match the `classNameFilter` RegExp if animations are globally disabled' ,
311
+ function ( ) {
312
+ var regex = / f o o / ;
313
+ var regexTestSpy = spyOn ( regex , 'test' ) . and . callThrough ( ) ;
314
+
315
+ module ( function ( $animateProvider ) {
316
+ $animateProvider . classNameFilter ( regex ) ;
317
+ } ) ;
318
+
319
+ inject ( function ( $animate ) {
320
+ $animate . addClass ( element , 'foo' ) ;
321
+ expect ( regexTestSpy ) . toHaveBeenCalled ( ) ;
322
+
323
+ regexTestSpy . calls . reset ( ) ;
324
+ $animate . enabled ( false ) ;
325
+ $animate . addClass ( element , 'bar' ) ;
326
+ expect ( regexTestSpy ) . not . toHaveBeenCalled ( ) ;
327
+
328
+ regexTestSpy . calls . reset ( ) ;
329
+ $animate . enabled ( true ) ;
330
+ $animate . addClass ( element , 'baz' ) ;
331
+ expect ( regexTestSpy ) . toHaveBeenCalled ( ) ;
332
+ } ) ;
333
+ }
334
+ ) ;
335
+
310
336
describe ( 'customFilter()' , function ( ) {
311
337
it ( 'should be `null` by default' , module ( function ( $animateProvider ) {
312
338
expect ( $animateProvider . customFilter ( ) ) . toBeNull ( ) ;
@@ -434,6 +460,29 @@ describe('animations', function() {
434
460
expect ( element . parent ( ) [ 0 ] ) . toBeUndefined ( ) ;
435
461
} ) ;
436
462
} ) ;
463
+
464
+ it ( 'should not execute the function if animations are globally disabled' , function ( ) {
465
+ var customFilterSpy = jasmine . createSpy ( 'customFilterFn' ) ;
466
+
467
+ module ( function ( $animateProvider ) {
468
+ $animateProvider . customFilter ( customFilterSpy ) ;
469
+ } ) ;
470
+
471
+ inject ( function ( $animate ) {
472
+ $animate . addClass ( element , 'foo' ) ;
473
+ expect ( customFilterSpy ) . toHaveBeenCalled ( ) ;
474
+
475
+ customFilterSpy . calls . reset ( ) ;
476
+ $animate . enabled ( false ) ;
477
+ $animate . addClass ( element , 'bar' ) ;
478
+ expect ( customFilterSpy ) . not . toHaveBeenCalled ( ) ;
479
+
480
+ customFilterSpy . calls . reset ( ) ;
481
+ $animate . enabled ( true ) ;
482
+ $animate . addClass ( element , 'baz' ) ;
483
+ expect ( customFilterSpy ) . toHaveBeenCalled ( ) ;
484
+ } ) ;
485
+ } ) ;
437
486
} ) ;
438
487
439
488
describe ( 'enabled()' , function ( ) {
0 commit comments