@@ -307,6 +307,32 @@ describe('animations', function() {
307307 } ) ;
308308 } ) ;
309309
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+
310336 describe ( 'customFilter()' , function ( ) {
311337 it ( 'should be `null` by default' , module ( function ( $animateProvider ) {
312338 expect ( $animateProvider . customFilter ( ) ) . toBeNull ( ) ;
@@ -434,6 +460,29 @@ describe('animations', function() {
434460 expect ( element . parent ( ) [ 0 ] ) . toBeUndefined ( ) ;
435461 } ) ;
436462 } ) ;
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+ } ) ;
437486 } ) ;
438487
439488 describe ( 'enabled()' , function ( ) {
0 commit comments