@@ -62,7 +62,7 @@ test('should return `null` if root node is removed', (t) => {
62
62
test ( 'should cascade-remove parent nodes' , ( t ) => {
63
63
const tree = u ( 'root' , [ u ( 'node' , [ u ( 'leaf' , '1' ) ] ) , u ( 'leaf' , '2' ) ] )
64
64
const children = tree . children
65
- // @ts -ignore it exists!
65
+ // @ts -expect-error it exists!
66
66
const first = children [ 0 ] . children [ 0 ]
67
67
const last = children [ 1 ]
68
68
@@ -117,19 +117,11 @@ test('should support type tests', (t) => {
117
117
test ( 'should support function tests' , ( t ) => {
118
118
const tree = u ( 'node' , [ u ( 'node' , [ u ( 'leaf' , '1' ) ] ) , u ( 'leaf' , '2' ) ] )
119
119
120
- remove ( tree , { cascade : false } , test )
120
+ remove ( tree , { cascade : false } , ( node ) => literal ( node ) && node . value === '1' )
121
121
122
122
t . deepEqual ( tree , u ( 'node' , [ u ( 'node' , [ ] ) , u ( 'leaf' , '2' ) ] ) )
123
123
124
124
t . end ( )
125
-
126
- /**
127
- * @param {Literal } node
128
- * @returns {boolean }
129
- */
130
- function test ( node ) {
131
- return node . value === '1'
132
- }
133
125
} )
134
126
135
127
test ( 'opts.cascade = true' , ( t ) => {
@@ -146,7 +138,7 @@ test('opts.cascade = false', (t) => {
146
138
const tree = u ( 'root' , [ u ( 'node' , [ u ( 'leaf' , '1' ) ] ) , u ( 'leaf' , '2' ) ] )
147
139
const siblings = tree . children
148
140
const node = siblings [ 0 ]
149
- // @ts -ignore it exists!
141
+ // @ts -expect-error it exists!
150
142
const children = node . children
151
143
152
144
const next = remove ( tree , { cascade : false } , 'leaf' )
@@ -155,7 +147,7 @@ test('opts.cascade = false', (t) => {
155
147
t . deepEqual ( tree , u ( 'root' , [ u ( 'node' , [ ] ) ] ) )
156
148
t . equal ( tree . children , siblings )
157
149
t . equal ( tree . children [ 0 ] , node )
158
- // @ts -ignore it exists!
150
+ // @ts -expect-error it exists!
159
151
t . equal ( tree . children [ 0 ] . children , children )
160
152
161
153
t . end ( )
@@ -179,3 +171,11 @@ test('example from readme', (t) => {
179
171
180
172
t . end ( )
181
173
} )
174
+
175
+ /**
176
+ * @param {Node } node
177
+ * @returns {node is Literal }
178
+ */
179
+ function literal ( node ) {
180
+ return 'value' in node
181
+ }
0 commit comments