@@ -352,6 +352,18 @@ describe("$animator", function() {
352
352
expect ( element . hasClass ( 'animation-cancelled' ) ) . toBe ( true ) ;
353
353
} ) ) ;
354
354
355
+
356
+ it ( "should properly animate custom animation events" , inject ( function ( $animator , $rootScope ) {
357
+ $animator . enabled ( true ) ;
358
+ animator = $animator ( $rootScope , {
359
+ ngAnimate : '{custom: \'setup-memo\'}'
360
+ } ) ;
361
+
362
+ element . text ( '123' ) ;
363
+ animator . animate ( 'custom' , element ) ;
364
+ window . setTimeout . expect ( 1 ) . process ( ) ;
365
+ expect ( element . text ( ) ) . toBe ( 'memento' ) ;
366
+ } ) ) ;
355
367
} ) ;
356
368
357
369
describe ( "with CSS3" , function ( ) {
@@ -368,6 +380,64 @@ describe("$animator", function() {
368
380
} )
369
381
} ) ;
370
382
383
+ it ( "should properly animate custom animations for specific animation events" ,
384
+ inject ( function ( $animator , $rootScope , $compile , $sniffer ) {
385
+
386
+ $animator . enabled ( true ) ;
387
+ var element = $compile ( html ( '<div></div>' ) ) ( $rootScope ) ;
388
+
389
+ animator = $animator ( $rootScope , {
390
+ ngAnimate : '{custom: \'special\'}'
391
+ } ) ;
392
+
393
+ animator . animate ( 'custom' , element ) ;
394
+ if ( $sniffer . transitions ) {
395
+ expect ( element . hasClass ( 'special' ) ) . toBe ( true ) ;
396
+ window . setTimeout . expect ( 1 ) . process ( ) ;
397
+ expect ( element . hasClass ( 'special-active' ) ) . toBe ( true ) ;
398
+ }
399
+ else {
400
+ expect ( window . setTimeout . queue . length ) . toBe ( 0 ) ;
401
+ }
402
+ } ) ) ;
403
+
404
+ it ( "should not animate custom animations if not specifically defined" ,
405
+ inject ( function ( $animator , $rootScope , $compile ) {
406
+
407
+ $animator . enabled ( true ) ;
408
+ var element = $compile ( html ( '<div></div>' ) ) ( $rootScope ) ;
409
+
410
+ animator = $animator ( $rootScope , {
411
+ ngAnimate : '{custom: \'special\'}'
412
+ } ) ;
413
+
414
+ expect ( window . setTimeout . queue . length ) . toBe ( 0 ) ;
415
+ animator . animate ( 'custom1' , element ) ;
416
+ expect ( element . hasClass ( 'special' ) ) . toBe ( false ) ;
417
+ expect ( window . setTimeout . queue . length ) . toBe ( 0 ) ;
418
+ } ) ) ;
419
+
420
+ it ( "should properly animate custom animations for general animation events" ,
421
+ inject ( function ( $animator , $rootScope , $compile , $sniffer ) {
422
+
423
+ $animator . enabled ( true ) ;
424
+ var element = $compile ( html ( '<div></div>' ) ) ( $rootScope ) ;
425
+
426
+ animator = $animator ( $rootScope , {
427
+ ngAnimate : "'special'"
428
+ } ) ;
429
+
430
+ animator . animate ( 'custom' , element ) ;
431
+ if ( $sniffer . transitions ) {
432
+ expect ( element . hasClass ( 'special-custom' ) ) . toBe ( true ) ;
433
+ window . setTimeout . expect ( 1 ) . process ( ) ;
434
+ expect ( element . hasClass ( 'special-custom-active' ) ) . toBe ( true ) ;
435
+ }
436
+ else {
437
+ expect ( window . setTimeout . queue . length ) . toBe ( 0 ) ;
438
+ }
439
+ } ) ) ;
440
+
371
441
describe ( "Animations" , function ( ) {
372
442
it ( "should properly detect and make use of CSS Animations" ,
373
443
inject ( function ( $animator , $rootScope , $compile , $sniffer ) {
0 commit comments