@@ -12,12 +12,12 @@ import test from 'tape'
12
12
import { u } from 'unist-builder'
13
13
import { remove } from './index.js'
14
14
15
- test ( 'should compare nodes by partial properties' , function ( t ) {
16
- var tree = u ( 'node' , [ u ( 'leaf' , '1' ) , u ( 'leaf' , '2' ) ] )
17
- var children = tree . children
18
- var first = tree . children [ 0 ]
15
+ test ( 'should compare nodes by partial properties' , ( t ) => {
16
+ const tree = u ( 'node' , [ u ( 'leaf' , '1' ) , u ( 'leaf' , '2' ) ] )
17
+ const children = tree . children
18
+ const first = tree . children [ 0 ]
19
19
20
- var next = remove ( tree , { value : '2' } )
20
+ const next = remove ( tree , { value : '2' } )
21
21
22
22
t . equal ( next , tree )
23
23
t . deepEqual ( tree , u ( 'node' , [ first ] ) )
@@ -27,13 +27,13 @@ test('should compare nodes by partial properties', function (t) {
27
27
t . end ( )
28
28
} )
29
29
30
- test ( 'should remove nodes with children' , function ( t ) {
31
- var tree = u ( 'root' , [ u ( 'node' , [ u ( 'leaf' , '1' ) ] ) , u ( 'leaf' , '2' ) ] )
32
- var children = tree . children
33
- var first = tree . children [ 0 ]
34
- var last = tree . children [ 1 ]
30
+ test ( 'should remove nodes with children' , ( t ) => {
31
+ const tree = u ( 'root' , [ u ( 'node' , [ u ( 'leaf' , '1' ) ] ) , u ( 'leaf' , '2' ) ] )
32
+ const children = tree . children
33
+ const first = tree . children [ 0 ]
34
+ const last = tree . children [ 1 ]
35
35
36
- var next = remove ( tree , test )
36
+ const next = remove ( tree , test )
37
37
38
38
t . equal ( next , tree )
39
39
t . deepEqual ( tree , u ( 'root' , [ last ] ) )
@@ -51,22 +51,22 @@ test('should remove nodes with children', function (t) {
51
51
}
52
52
} )
53
53
54
- test ( 'should return `null` if root node is removed' , function ( t ) {
55
- var tree = u ( 'root' , [ u ( 'node' , [ u ( 'leaf' , '1' ) ] ) , u ( 'leaf' , '2' ) ] )
54
+ test ( 'should return `null` if root node is removed' , ( t ) => {
55
+ const tree = u ( 'root' , [ u ( 'node' , [ u ( 'leaf' , '1' ) ] ) , u ( 'leaf' , '2' ) ] )
56
56
57
57
t . equal ( remove ( tree , 'root' ) , null )
58
58
59
59
t . end ( )
60
60
} )
61
61
62
- test ( 'should cascade-remove parent nodes' , function ( t ) {
63
- var tree = u ( 'root' , [ u ( 'node' , [ u ( 'leaf' , '1' ) ] ) , u ( 'leaf' , '2' ) ] )
64
- var children = tree . children
62
+ test ( 'should cascade-remove parent nodes' , ( t ) => {
63
+ const tree = u ( 'root' , [ u ( 'node' , [ u ( 'leaf' , '1' ) ] ) , u ( 'leaf' , '2' ) ] )
64
+ const children = tree . children
65
65
// @ts -ignore it exists!
66
- var first = children [ 0 ] . children [ 0 ]
67
- var last = children [ 1 ]
66
+ const first = children [ 0 ] . children [ 0 ]
67
+ const last = children [ 1 ]
68
68
69
- var next = remove ( tree , test )
69
+ const next = remove ( tree , test )
70
70
71
71
t . equal ( next , tree )
72
72
t . deepEqual ( tree , u ( 'root' , [ last ] ) )
@@ -84,18 +84,18 @@ test('should cascade-remove parent nodes', function (t) {
84
84
}
85
85
} )
86
86
87
- test ( 'should cascade-remove root nodes' , function ( t ) {
88
- var tree = u ( 'root' , [ u ( 'node' , [ u ( 'leaf' , '1' ) ] ) , u ( 'leaf' , '2' ) ] )
87
+ test ( 'should cascade-remove root nodes' , ( t ) => {
88
+ const tree = u ( 'root' , [ u ( 'node' , [ u ( 'leaf' , '1' ) ] ) , u ( 'leaf' , '2' ) ] )
89
89
90
- var next = remove ( tree , 'leaf' )
90
+ const next = remove ( tree , 'leaf' )
91
91
92
92
t . equal ( next , null )
93
93
94
94
t . end ( )
95
95
} )
96
96
97
- test ( 'should not cascade-remove nodes that were empty initially' , function ( t ) {
98
- var tree = u ( 'node' , [ u ( 'node' , [ ] ) , u ( 'node' , [ u ( 'leaf' ) ] ) ] )
97
+ test ( 'should not cascade-remove nodes that were empty initially' , ( t ) => {
98
+ const tree = u ( 'node' , [ u ( 'node' , [ ] ) , u ( 'node' , [ u ( 'leaf' ) ] ) ] )
99
99
100
100
remove ( tree , 'leaf' )
101
101
@@ -104,8 +104,8 @@ test('should not cascade-remove nodes that were empty initially', function (t) {
104
104
t . end ( )
105
105
} )
106
106
107
- test ( 'should support type tests' , function ( t ) {
108
- var tree = u ( 'node' , [ u ( 'node' , [ u ( 'leaf' , '1' ) ] ) , u ( 'leaf' , '2' ) ] )
107
+ test ( 'should support type tests' , ( t ) => {
108
+ const tree = u ( 'node' , [ u ( 'node' , [ u ( 'leaf' , '1' ) ] ) , u ( 'leaf' , '2' ) ] )
109
109
110
110
remove ( tree , { cascade : false } , 'leaf' )
111
111
@@ -114,8 +114,8 @@ test('should support type tests', function (t) {
114
114
t . end ( )
115
115
} )
116
116
117
- test ( 'should support function tests' , function ( t ) {
118
- var tree = u ( 'node' , [ u ( 'node' , [ u ( 'leaf' , '1' ) ] ) , u ( 'leaf' , '2' ) ] )
117
+ test ( 'should support function tests' , ( t ) => {
118
+ const tree = u ( 'node' , [ u ( 'node' , [ u ( 'leaf' , '1' ) ] ) , u ( 'leaf' , '2' ) ] )
119
119
120
120
remove ( tree , { cascade : false } , test )
121
121
@@ -132,24 +132,24 @@ test('should support function tests', function (t) {
132
132
}
133
133
} )
134
134
135
- test ( 'opts.cascade = true' , function ( t ) {
136
- var tree = u ( 'root' , [ u ( 'node' , [ u ( 'leaf' , '1' ) ] ) , u ( 'leaf' , '2' ) ] )
135
+ test ( 'opts.cascade = true' , ( t ) => {
136
+ const tree = u ( 'root' , [ u ( 'node' , [ u ( 'leaf' , '1' ) ] ) , u ( 'leaf' , '2' ) ] )
137
137
138
- var next = remove ( tree , { cascade : true } , 'leaf' )
138
+ const next = remove ( tree , { cascade : true } , 'leaf' )
139
139
140
140
t . equal ( next , null )
141
141
142
142
t . end ( )
143
143
} )
144
144
145
- test ( 'opts.cascade = false' , function ( t ) {
146
- var tree = u ( 'root' , [ u ( 'node' , [ u ( 'leaf' , '1' ) ] ) , u ( 'leaf' , '2' ) ] )
147
- var siblings = tree . children
148
- var node = siblings [ 0 ]
145
+ test ( 'opts.cascade = false' , ( t ) => {
146
+ const tree = u ( 'root' , [ u ( 'node' , [ u ( 'leaf' , '1' ) ] ) , u ( 'leaf' , '2' ) ] )
147
+ const siblings = tree . children
148
+ const node = siblings [ 0 ]
149
149
// @ts -ignore it exists!
150
- var children = node . children
150
+ const children = node . children
151
151
152
- var next = remove ( tree , { cascade : false } , 'leaf' )
152
+ const next = remove ( tree , { cascade : false } , 'leaf' )
153
153
154
154
t . equal ( next , tree )
155
155
t . deepEqual ( tree , u ( 'root' , [ u ( 'node' , [ ] ) ] ) )
@@ -161,8 +161,8 @@ test('opts.cascade = false', function (t) {
161
161
t . end ( )
162
162
} )
163
163
164
- test ( 'example from readme' , function ( t ) {
165
- var tree = u ( 'root' , [
164
+ test ( 'example from readme' , ( t ) => {
165
+ const tree = u ( 'root' , [
166
166
u ( 'leaf' , '1' ) ,
167
167
u ( 'node' , [
168
168
u ( 'leaf' , '2' ) ,
0 commit comments