@@ -24,12 +24,9 @@ test('remove', async function (t) {
24
24
/** @type {Emphasis } */
25
25
const tree = u ( 'emphasis' , children )
26
26
27
- const next = remove ( tree , { value : '2' } )
27
+ remove ( tree , { value : '2' } )
28
28
29
29
assert . deepEqual ( tree , u ( 'emphasis' , [ leaf1 ] ) )
30
- assert . equal ( next , tree )
31
- assert . equal ( next . children , children )
32
- assert . equal ( next . children [ 0 ] , leaf1 )
33
30
} )
34
31
35
32
await t . test ( 'should remove parent nodes' , function ( ) {
@@ -40,12 +37,9 @@ test('remove', async function (t) {
40
37
/** @type {Root } */
41
38
const tree = u ( 'root' , children )
42
39
43
- const next = remove ( tree , test )
40
+ remove ( tree , test )
44
41
45
42
assert . deepEqual ( tree , u ( 'root' , [ leaf2 ] ) )
46
- assert . equal ( next , tree )
47
- assert . equal ( next . children , children )
48
- assert . equal ( next . children [ 0 ] , leaf2 )
49
43
50
44
/**
51
45
* @param {Node } node
@@ -56,23 +50,25 @@ test('remove', async function (t) {
56
50
}
57
51
} )
58
52
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' ) ] )
65
56
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
+ } )
69
64
70
65
await t . test ( 'should cascade (remove) root nodes' , function ( ) {
71
66
/** @type {Root } */
72
67
const tree = u ( 'root' , [ u ( 'emphasis' , [ u ( 'text' , '1' ) ] ) , u ( 'text' , '2' ) ] )
73
- const next = remove ( tree , 'text' )
74
68
75
- assert . equal ( next , undefined )
69
+ remove ( tree , 'text' )
70
+
71
+ assert . deepEqual ( tree , u ( 'root' , [ ] ) )
76
72
} )
77
73
78
74
await t . test (
@@ -122,9 +118,8 @@ test('remove', async function (t) {
122
118
await t . test ( 'should support `cascade = true`' , function ( ) {
123
119
/** @type {Root } */
124
120
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' , [ ] ) )
128
123
} )
129
124
130
125
await t . test ( 'should support `cascade = false`' , function ( ) {
@@ -136,13 +131,9 @@ test('remove', async function (t) {
136
131
/** @type {Root } */
137
132
const tree = u ( 'root' , siblings )
138
133
139
- const next = remove ( tree , { cascade : false } , 'text' )
134
+ remove ( tree , { cascade : false } , 'text' )
140
135
141
136
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 )
146
137
} )
147
138
148
139
await t . test ( 'should support the example from readme' , function ( ) {
0 commit comments