@@ -636,6 +636,24 @@ test('insertBefore() receives array', () => {
636636 is ( a . toString ( ) , 'a{ color: red; width: 1; height: 2; z-index: 1 }' )
637637} )
638638
639+ test ( 'insertBefore() receives pre-existing child node - a' , ( ) => {
640+ let a = parse ( 'a{ align-items: start; color: red; z-index: 1 }' )
641+ let declA = ( a . first as Rule ) . nodes [ 0 ] ;
642+ let declC = ( a . first as Rule ) . nodes [ 2 ] ;
643+ declC . before ( declA ) ;
644+
645+ is ( a . toString ( ) , 'a{ color: red; align-items: start; z-index: 1 }' )
646+ } )
647+
648+ test ( 'insertBefore() receives pre-existing child node - b' , ( ) => {
649+ let a = parse ( 'a{ align-items: start; color: red; z-index: 1 }' )
650+ let declA = ( a . first as Rule ) . nodes [ 0 ] ;
651+ let declC = ( a . first as Rule ) . nodes [ 2 ] ;
652+ declA . before ( declC ) ;
653+
654+ is ( a . toString ( ) , 'a{ z-index: 1; align-items: start; color: red }' )
655+ } )
656+
639657test ( 'insertAfter() inserts child' , ( ) => {
640658 let rule = parse ( 'a { a: 1; b: 2 }' ) . first as Rule
641659 rule . insertAfter ( 0 , { prop : 'c' , value : '3' } )
@@ -666,6 +684,24 @@ test('insertAfter() receives array', () => {
666684 is ( a . toString ( ) , 'a{ color: red; width: 1; height: 2; z-index: 1 }' )
667685} )
668686
687+ test ( 'insertAfter() receives pre-existing child node - a' , ( ) => {
688+ let a = parse ( 'a{ align-items: start; color: red; z-index: 1 }' )
689+ let declA = ( a . first as Rule ) . nodes [ 0 ] ;
690+ let declC = ( a . first as Rule ) . nodes [ 2 ] ;
691+ declC . after ( declA ) ;
692+
693+ is ( a . toString ( ) , 'a{ color: red; z-index: 1; align-items: start }' )
694+ } )
695+
696+ test ( 'insertAfter() receives pre-existing child node - b' , ( ) => {
697+ let a = parse ( 'a{ align-items: start; color: red; z-index: 1 }' )
698+ let declA = ( a . first as Rule ) . nodes [ 0 ] ;
699+ let declC = ( a . first as Rule ) . nodes [ 2 ] ;
700+ declA . after ( declC ) ;
701+
702+ is ( a . toString ( ) , 'a{ align-items: start; z-index: 1; color: red }' )
703+ } )
704+
669705test ( 'removeChild() removes by index' , ( ) => {
670706 let rule = parse ( 'a { a: 1; b: 2 }' ) . first as Rule
671707 rule . removeChild ( 1 )
0 commit comments