@@ -1448,28 +1448,46 @@ describe("animations", function() {
14481448 } ) ) ;
14491449
14501450
1451- it ( 'should allow an element to be pinned elsewhere and still be available in animations' ,
1452- inject ( function ( $animate , $compile , $document , $rootElement , $rootScope ) {
1451+ they ( 'should animate an element inside a pinned element that is the $prop element' ,
1452+ [ 'same' , 'parent' , 'grandparent' ] ,
1453+ function ( elementRelation ) {
1454+ inject ( function ( $animate , $compile , $document , $rootElement , $rootScope ) {
14531455
1454- var innerParent = jqLite ( '<div></div>' ) ;
1455- jqLite ( $document [ 0 ] . body ) . append ( innerParent ) ;
1456- innerParent . append ( $rootElement ) ;
1456+ var pinElement , animateElement ;
14571457
1458- var element = jqLite ( '<div></div>' ) ;
1459- jqLite ( $document [ 0 ] . body ) . append ( element ) ;
1458+ var innerParent = jqLite ( '<div></div>' ) ;
1459+ jqLite ( $document [ 0 ] . body ) . append ( innerParent ) ;
1460+ innerParent . append ( $rootElement ) ;
14601461
1461- $animate . addClass ( element , 'red' ) ;
1462- $rootScope . $digest ( ) ;
1463- expect ( capturedAnimation ) . toBeFalsy ( ) ;
1462+ switch ( elementRelation ) {
1463+ case 'same' :
1464+ pinElement = jqLite ( '<div id="animate"></div>' ) ;
1465+ break ;
1466+ case 'parent' :
1467+ pinElement = jqLite ( '<div><div id="animate"></div></div>' ) ;
1468+ break ;
1469+ case 'grandparent' :
1470+ pinElement = jqLite ( '<div><div><div id="animate"></div></div></div>' ) ;
1471+ break ;
1472+ }
14641473
1465- $animate . pin ( element , $rootElement ) ;
1474+ jqLite ( $document [ 0 ] . body ) . append ( pinElement ) ;
1475+ animateElement = jqLite ( $document [ 0 ] . getElementById ( 'animate' ) ) ;
14661476
1467- $animate . addClass ( element , 'blue ' ) ;
1468- $rootScope . $digest ( ) ;
1469- expect ( capturedAnimation ) . toBeTruthy ( ) ;
1477+ $animate . addClass ( animateElement , 'red ' ) ;
1478+ $rootScope . $digest ( ) ;
1479+ expect ( capturedAnimation ) . toBeFalsy ( ) ;
14701480
1471- dealoc ( element ) ;
1472- } ) ) ;
1481+ // Pin the element to the app root to enable animations
1482+ $animate . pin ( pinElement , $rootElement ) ;
1483+
1484+ $animate . addClass ( animateElement , 'blue' ) ;
1485+ $rootScope . $digest ( ) ;
1486+ expect ( capturedAnimation ) . toBeTruthy ( ) ;
1487+
1488+ dealoc ( pinElement ) ;
1489+ } ) ;
1490+ } ) ;
14731491
14741492 it ( 'should adhere to the disabled state of the hosted parent when an element is pinned' ,
14751493 inject ( function ( $animate , $compile , $document , $rootElement , $rootScope ) {
0 commit comments