@@ -654,6 +654,28 @@ test('insertBefore() receives pre-existing child node - b', () => {
654654 is ( a . toString ( ) , 'a{ z-index: 1; align-items: start; color: red }' )
655655} )
656656
657+ test ( 'insertBefore() has defined way of adding newlines' , ( ) => {
658+ let root = parse ( 'a {}' )
659+ root . insertBefore ( root . first as Rule , 'b {}' )
660+ root . insertBefore ( root . first as Rule , 'c {}' )
661+ is ( root . toString ( ) , 'c {}\nb {}\na {}' )
662+
663+ root = parse ( 'other {}a {}' )
664+ root . insertBefore ( root . first as Rule , 'b {}' )
665+ root . insertBefore ( root . first as Rule , 'c {}' )
666+ is ( root . toString ( ) , 'c {}b {}other {}a {}' )
667+
668+ root = parse ( 'other {}\na {}' )
669+ root . insertBefore ( root . nodes [ 1 ] as Rule , 'b {}' )
670+ root . insertBefore ( root . nodes [ 1 ] as Rule , 'c {}' )
671+ is ( root . toString ( ) , 'other {}\nc {}\nb {}\na {}' )
672+
673+ root = parse ( 'other {}a {}' )
674+ root . insertBefore ( root . nodes [ 1 ] as Rule , 'b {}' )
675+ root . insertBefore ( root . nodes [ 1 ] as Rule , 'c {}' )
676+ is ( root . toString ( ) , 'other {}c {}b {}a {}' )
677+ } )
678+
657679test ( 'insertAfter() inserts child' , ( ) => {
658680 let rule = parse ( 'a { a: 1; b: 2 }' ) . first as Rule
659681 rule . insertAfter ( 0 , { prop : 'c' , value : '3' } )
0 commit comments