@@ -44,9 +44,7 @@ test('findAndReplace', (t) => {
44
44
findAndReplace (
45
45
create ( ) ,
46
46
/ e m ( \w + ) i s / ,
47
- ( /** @type {string } */ _ , /** @type {string } */ $1 ) => {
48
- return '[' + $1 + ']'
49
- }
47
+ ( /** @type {string } */ _ , /** @type {string } */ $1 ) => '[' + $1 + ']'
50
48
) ,
51
49
h ( 'p' , [
52
50
'Some ' ,
@@ -61,9 +59,21 @@ test('findAndReplace', (t) => {
61
59
)
62
60
63
61
t . deepEqual (
64
- findAndReplace ( create ( ) , 'emphasis' , ( ) => {
65
- return h ( 'a' , h ( 'b' , 'c' ) )
66
- } ) ,
62
+ findAndReplace ( create ( ) , 'emphasis' , ( ) => '' ) ,
63
+ h ( 'p' , [
64
+ 'Some ' ,
65
+ h ( 'em' ) ,
66
+ ', ' ,
67
+ h ( 'strong' , 'importance' ) ,
68
+ ', and ' ,
69
+ h ( 'code' , 'code' ) ,
70
+ '.'
71
+ ] ) ,
72
+ 'should work when given `replace` returns an empty string'
73
+ )
74
+
75
+ t . deepEqual (
76
+ findAndReplace ( create ( ) , 'emphasis' , ( ) => h ( 'a' , h ( 'b' , 'c' ) ) ) ,
67
77
h ( 'p' , [
68
78
'Some ' ,
69
79
h ( 'em' , h ( 'a' , h ( 'b' , 'c' ) ) ) ,
@@ -76,6 +86,20 @@ test('findAndReplace', (t) => {
76
86
'should work when given `replace` returns a node'
77
87
)
78
88
89
+ t . deepEqual (
90
+ findAndReplace ( create ( ) , 'emphasis' , ( ) => [ h ( 'a' ) , h ( 'b' , 'c' ) ] ) ,
91
+ h ( 'p' , [
92
+ 'Some ' ,
93
+ h ( 'em' , [ h ( 'a' ) , h ( 'b' , 'c' ) ] ) ,
94
+ ', ' ,
95
+ h ( 'strong' , 'importance' ) ,
96
+ ', and ' ,
97
+ h ( 'code' , 'code' ) ,
98
+ '.'
99
+ ] ) ,
100
+ 'should work when given `replace` returns a list of nodes'
101
+ )
102
+
79
103
t . deepEqual (
80
104
findAndReplace ( create ( ) , [
81
105
[ 'emphasis' , '!!!' ] ,
@@ -233,9 +257,7 @@ test('findAndReplace', (t) => {
233
257
)
234
258
235
259
t . deepEqual (
236
- findAndReplace ( create ( ) , 'and' , ( ) => {
237
- return h ( 'script' , 'alert(1)' )
238
- } ) ,
260
+ findAndReplace ( create ( ) , 'and' , ( ) => h ( 'script' , 'alert(1)' ) ) ,
239
261
h ( 'p' , [
240
262
'Some ' ,
241
263
h ( 'em' , 'emphasis' ) ,
0 commit comments