1
- import test from 'tape'
1
+ import assert from 'node:assert/strict'
2
+ import test from 'node:test'
2
3
import { u } from 'unist-builder'
3
4
import { findAndReplace } from './index.js'
4
5
5
- test ( 'findAndReplace' , ( t ) => {
6
- t . throws (
6
+ test ( 'findAndReplace' , ( ) => {
7
+ assert . throws (
7
8
( ) => {
8
9
// @ts -expect-error runtime.
9
10
findAndReplace ( create ( ) , true )
@@ -12,7 +13,7 @@ test('findAndReplace', (t) => {
12
13
'should throw on invalid search and replaces'
13
14
)
14
15
15
- t . deepEqual (
16
+ assert . deepEqual (
16
17
findAndReplace ( create ( ) , 'emphasis' ) ,
17
18
u ( 'paragraph' , [
18
19
u ( 'text' , 'Some ' ) ,
@@ -26,7 +27,7 @@ test('findAndReplace', (t) => {
26
27
'should remove without `replace`'
27
28
)
28
29
29
- t . deepEqual (
30
+ assert . deepEqual (
30
31
findAndReplace ( create ( ) , 'emphasis' , '!!!' ) ,
31
32
u ( 'paragraph' , [
32
33
u ( 'text' , 'Some ' ) ,
@@ -40,7 +41,7 @@ test('findAndReplace', (t) => {
40
41
'should work when given `find` and `replace`'
41
42
)
42
43
43
- t . deepEqual (
44
+ assert . deepEqual (
44
45
findAndReplace (
45
46
create ( ) ,
46
47
/ e m ( \w + ) i s / ,
@@ -58,7 +59,7 @@ test('findAndReplace', (t) => {
58
59
'should work when given `find` as a `RegExp` and `replace` as a `Function`'
59
60
)
60
61
61
- t . deepEqual (
62
+ assert . deepEqual (
62
63
findAndReplace ( create ( ) , 'emphasis' , ( ) => '' ) ,
63
64
u ( 'paragraph' , [
64
65
u ( 'text' , 'Some ' ) ,
@@ -72,7 +73,7 @@ test('findAndReplace', (t) => {
72
73
'should work when given `replace` returns an empty string'
73
74
)
74
75
75
- t . deepEqual (
76
+ assert . deepEqual (
76
77
findAndReplace ( create ( ) , 'emphasis' , ( ) => u ( 'delete' , [ u ( 'break' ) ] ) ) ,
77
78
u ( 'paragraph' , [
78
79
u ( 'text' , 'Some ' ) ,
@@ -86,7 +87,7 @@ test('findAndReplace', (t) => {
86
87
'should work when given `replace` returns a node'
87
88
)
88
89
89
- t . deepEqual (
90
+ assert . deepEqual (
90
91
findAndReplace ( create ( ) , 'emphasis' , ( ) => [ u ( 'delete' , [ ] ) , u ( 'break' ) ] ) ,
91
92
u ( 'paragraph' , [
92
93
u ( 'text' , 'Some ' ) ,
@@ -100,7 +101,7 @@ test('findAndReplace', (t) => {
100
101
'should work when given `replace` returns a list of nodes'
101
102
)
102
103
103
- t . deepEqual (
104
+ assert . deepEqual (
104
105
findAndReplace ( create ( ) , [
105
106
[ 'emphasis' , '!!!' ] ,
106
107
[ 'importance' , '???' ]
@@ -117,7 +118,7 @@ test('findAndReplace', (t) => {
117
118
'should work when given `search` as an matrix of strings'
118
119
)
119
120
120
- t . deepEqual (
121
+ assert . deepEqual (
121
122
findAndReplace ( create ( ) , { emp : 'hacks' , ',' : '!' } ) ,
122
123
u ( 'paragraph' , [
123
124
u ( 'text' , 'Some ' ) ,
@@ -133,7 +134,7 @@ test('findAndReplace', (t) => {
133
134
'should work when given `search` as an object of strings'
134
135
)
135
136
136
- t . deepEqual (
137
+ assert . deepEqual (
137
138
findAndReplace ( create ( ) , / \B m p \B / , '[MP]' ) ,
138
139
u ( 'paragraph' , [
139
140
u ( 'text' , 'Some ' ) ,
@@ -147,7 +148,7 @@ test('findAndReplace', (t) => {
147
148
'should work on partial matches'
148
149
)
149
150
150
- t . deepEqual (
151
+ assert . deepEqual (
151
152
findAndReplace ( create ( ) , {
152
153
emphasis ( ) {
153
154
return u ( 'link' , { url : 'x' } , [ u ( 'text' , 'importance' ) ] )
@@ -166,7 +167,7 @@ test('findAndReplace', (t) => {
166
167
'should find-and-replace recursively'
167
168
)
168
169
169
- t . deepEqual (
170
+ assert . deepEqual (
170
171
findAndReplace (
171
172
u ( 'paragraph' , [
172
173
u ( 'text' , 'Some ' ) ,
@@ -189,7 +190,7 @@ test('findAndReplace', (t) => {
189
190
'should ignore from options'
190
191
)
191
192
192
- t . deepEqual (
193
+ assert . deepEqual (
193
194
findAndReplace (
194
195
u ( 'paragraph' , [ u ( 'text' , 'Some emphasis, importance, and code.' ) ] ) ,
195
196
{
@@ -208,7 +209,7 @@ test('findAndReplace', (t) => {
208
209
'should not be order-sensitive with strings'
209
210
)
210
211
211
- t . deepEqual (
212
+ assert . deepEqual (
212
213
findAndReplace (
213
214
u ( 'paragraph' , [ u ( 'text' , 'Some emphasis, importance, and code.' ) ] ) ,
214
215
[
@@ -236,7 +237,7 @@ test('findAndReplace', (t) => {
236
237
'should not be order-sensitive with regexes'
237
238
)
238
239
239
- t . deepEqual (
240
+ assert . deepEqual (
240
241
findAndReplace ( u ( 'paragraph' , [ u ( 'text' , 'aaa bbb' ) ] ) , [
241
242
[
242
243
/ \b \w + \b / g,
@@ -255,7 +256,7 @@ test('findAndReplace', (t) => {
255
256
'should support a match, and then a `false`'
256
257
)
257
258
258
- t . deepEqual (
259
+ assert . deepEqual (
259
260
findAndReplace ( create ( ) , 'emphasis' , ( ) => false ) ,
260
261
u ( 'paragraph' , [
261
262
u ( 'text' , 'Some ' ) ,
@@ -269,7 +270,7 @@ test('findAndReplace', (t) => {
269
270
'should not replace when returning false'
270
271
)
271
272
272
- t . deepEqual (
273
+ assert . deepEqual (
273
274
findAndReplace (
274
275
u ( 'paragraph' , [ u ( 'text' , 'asd.' ) ] ) ,
275
276
'asd' ,
@@ -279,7 +280,7 @@ test('findAndReplace', (t) => {
279
280
'should not recurse into a replaced value'
280
281
)
281
282
282
- t . deepEqual (
283
+ assert . deepEqual (
283
284
findAndReplace (
284
285
u ( 'paragraph' , [ u ( 'text' , 'asd.' ) ] ) ,
285
286
'asd' ,
@@ -289,7 +290,7 @@ test('findAndReplace', (t) => {
289
290
'should not recurse into a replaced node (head)'
290
291
)
291
292
292
- t . deepEqual (
293
+ assert . deepEqual (
293
294
findAndReplace (
294
295
u ( 'paragraph' , [ u ( 'text' , '.asd' ) ] ) ,
295
296
'asd' ,
@@ -299,7 +300,7 @@ test('findAndReplace', (t) => {
299
300
'should not recurse into a replaced node (tail)'
300
301
)
301
302
302
- t . deepEqual (
303
+ assert . deepEqual (
303
304
findAndReplace (
304
305
u ( 'paragraph' , [ u ( 'text' , 'asd' ) ] ) ,
305
306
'asd' ,
@@ -309,7 +310,7 @@ test('findAndReplace', (t) => {
309
310
'should not recurse into a replaced node (head and tail)'
310
311
)
311
312
312
- t . deepEqual (
313
+ assert . deepEqual (
313
314
findAndReplace ( create ( ) , 'and' , 'alert(1)' ) ,
314
315
u ( 'paragraph' , [
315
316
u ( 'text' , 'Some ' ) ,
@@ -324,8 +325,6 @@ test('findAndReplace', (t) => {
324
325
] ) ,
325
326
'security: replacer as string (safe)'
326
327
)
327
-
328
- t . end ( )
329
328
} )
330
329
331
330
function create ( ) {
0 commit comments