@@ -766,6 +766,22 @@ describe('Basic RRDocument implementation', () => {
766766 expect ( node . contains ( child2 ) ) . toBeTruthy ( ) ;
767767 } ) ;
768768
769+ it ( 'can append a child with parent node' , ( ) => {
770+ const node = document . createElement ( 'div' ) ;
771+ const child = document . createElement ( 'span' ) ;
772+ expect ( node . appendChild ( child ) ) . toBe ( child ) ;
773+ expect ( node . childNodes ) . toEqual ( [ child ] ) ;
774+ expect ( node . appendChild ( child ) ) . toBe ( child ) ;
775+ expect ( node . childNodes ) . toEqual ( [ child ] ) ;
776+ expect ( child . parentNode ) . toBe ( node ) ;
777+
778+ const node1 = document . createElement ( 'div' ) ;
779+ expect ( node1 . appendChild ( child ) ) . toBe ( child ) ;
780+ expect ( node1 . childNodes ) . toEqual ( [ child ] ) ;
781+ expect ( child . parentNode ) . toBe ( node1 ) ;
782+ expect ( node . childNodes ) . toEqual ( [ ] ) ;
783+ } ) ;
784+
769785 it ( 'can insert new child before an existing child' , ( ) => {
770786 const node = document . createElement ( 'div' ) ;
771787 const child1 = document . createElement ( 'h1' ) ;
@@ -820,6 +836,25 @@ describe('Basic RRDocument implementation', () => {
820836 expect ( node . contains ( child1 ) ) . toBeTruthy ( ) ;
821837 } ) ;
822838
839+ it ( 'can insert a child with parent node' , ( ) => {
840+ const node = document . createElement ( 'div' ) ;
841+ const child1 = document . createElement ( 'h1' ) ;
842+ expect ( node . insertBefore ( child1 , null ) ) . toBe ( child1 ) ;
843+ expect ( node . childNodes ) . toEqual ( [ child1 ] ) ;
844+ expect ( node . insertBefore ( child1 , child1 ) ) . toBe ( child1 ) ;
845+ expect ( node . childNodes ) . toEqual ( [ child1 ] ) ;
846+ expect ( child1 . parentNode ) . toEqual ( node ) ;
847+
848+ const node2 = document . createElement ( 'div' ) ;
849+ const child2 = document . createElement ( 'h2' ) ;
850+ expect ( node2 . insertBefore ( child2 , null ) ) . toBe ( child2 ) ;
851+ expect ( node2 . childNodes ) . toEqual ( [ child2 ] ) ;
852+ expect ( node2 . insertBefore ( child1 , child2 ) ) . toBe ( child1 ) ;
853+ expect ( node2 . childNodes ) . toEqual ( [ child1 , child2 ] ) ;
854+ expect ( child1 . parentNode ) . toEqual ( node2 ) ;
855+ expect ( node . childNodes ) . toEqual ( [ ] ) ;
856+ } ) ;
857+
823858 it ( 'can remove an existing child' , ( ) => {
824859 const node = document . createElement ( 'div' ) ;
825860 const child1 = document . createElement ( 'h1' ) ;
0 commit comments