@@ -24,12 +24,9 @@ test('remove', async function (t) {
2424 /** @type {Emphasis } */
2525 const tree = u ( 'emphasis' , children )
2626
27- const next = remove ( tree , { value : '2' } )
27+ remove ( tree , { value : '2' } )
2828
2929 assert . deepEqual ( tree , u ( 'emphasis' , [ leaf1 ] ) )
30- assert . equal ( next , tree )
31- assert . equal ( next . children , children )
32- assert . equal ( next . children [ 0 ] , leaf1 )
3330 } )
3431
3532 await t . test ( 'should remove parent nodes' , function ( ) {
@@ -40,12 +37,9 @@ test('remove', async function (t) {
4037 /** @type {Root } */
4138 const tree = u ( 'root' , children )
4239
43- const next = remove ( tree , test )
40+ remove ( tree , test )
4441
4542 assert . deepEqual ( tree , u ( 'root' , [ leaf2 ] ) )
46- assert . equal ( next , tree )
47- assert . equal ( next . children , children )
48- assert . equal ( next . children [ 0 ] , leaf2 )
4943
5044 /**
5145 * @param {Node } node
@@ -56,23 +50,25 @@ test('remove', async function (t) {
5650 }
5751 } )
5852
59- await t . test (
60- 'should return `undefined` if root node is removed' ,
61- function ( ) {
62- /** @type {Root } */
63- const tree = u ( 'root' , [ u ( 'emphasis' , [ u ( 'text' , '1' ) ] ) , u ( 'text' , '2' ) ] )
64- const next = remove ( tree , 'root' )
53+ await t . test ( 'should not check root nodes' , function ( ) {
54+ /** @type {Root } */
55+ const tree = u ( 'root' , [ u ( 'emphasis' , [ u ( 'text' , '1' ) ] ) , u ( 'text' , '2' ) ] )
6556
66- assert . equal ( next , undefined )
67- }
68- )
57+ remove ( tree , 'root' )
58+
59+ assert . deepEqual (
60+ tree ,
61+ u ( 'root' , [ u ( 'emphasis' , [ u ( 'text' , '1' ) ] ) , u ( 'text' , '2' ) ] )
62+ )
63+ } )
6964
7065 await t . test ( 'should cascade (remove) root nodes' , function ( ) {
7166 /** @type {Root } */
7267 const tree = u ( 'root' , [ u ( 'emphasis' , [ u ( 'text' , '1' ) ] ) , u ( 'text' , '2' ) ] )
73- const next = remove ( tree , 'text' )
7468
75- assert . equal ( next , undefined )
69+ remove ( tree , 'text' )
70+
71+ assert . deepEqual ( tree , u ( 'root' , [ ] ) )
7672 } )
7773
7874 await t . test (
@@ -122,9 +118,8 @@ test('remove', async function (t) {
122118 await t . test ( 'should support `cascade = true`' , function ( ) {
123119 /** @type {Root } */
124120 const tree = u ( 'root' , [ u ( 'emphasis' , [ u ( 'text' , '1' ) ] ) , u ( 'text' , '2' ) ] )
125- const next = remove ( tree , { cascade : true } , 'text' )
126-
127- assert . equal ( next , undefined )
121+ remove ( tree , { cascade : true } , 'text' )
122+ assert . deepEqual ( tree , u ( 'root' , [ ] ) )
128123 } )
129124
130125 await t . test ( 'should support `cascade = false`' , function ( ) {
@@ -136,13 +131,9 @@ test('remove', async function (t) {
136131 /** @type {Root } */
137132 const tree = u ( 'root' , siblings )
138133
139- const next = remove ( tree , { cascade : false } , 'text' )
134+ remove ( tree , { cascade : false } , 'text' )
140135
141136 assert . deepEqual ( tree , u ( 'root' , [ u ( 'emphasis' , [ ] ) ] ) )
142- assert . equal ( next , tree )
143- assert . equal ( next . children , siblings )
144- assert . equal ( next . children [ 0 ] , node )
145- assert . equal ( next . children [ 0 ] . children , nodeChildren )
146137 } )
147138
148139 await t . test ( 'should support the example from readme' , function ( ) {
0 commit comments