1- import test from 'tape'
1+ import assert from 'node:assert/strict'
2+ import test from 'node:test'
23import { u } from 'unist-builder'
34import { findAndReplace } from './index.js'
45
5- test ( 'findAndReplace' , ( t ) => {
6- t . throws (
6+ test ( 'findAndReplace' , ( ) => {
7+ assert . throws (
78 ( ) => {
89 // @ts -expect-error runtime.
910 findAndReplace ( create ( ) , true )
@@ -12,7 +13,7 @@ test('findAndReplace', (t) => {
1213 'should throw on invalid search and replaces'
1314 )
1415
15- t . deepEqual (
16+ assert . deepEqual (
1617 findAndReplace ( create ( ) , 'emphasis' ) ,
1718 u ( 'paragraph' , [
1819 u ( 'text' , 'Some ' ) ,
@@ -26,7 +27,7 @@ test('findAndReplace', (t) => {
2627 'should remove without `replace`'
2728 )
2829
29- t . deepEqual (
30+ assert . deepEqual (
3031 findAndReplace ( create ( ) , 'emphasis' , '!!!' ) ,
3132 u ( 'paragraph' , [
3233 u ( 'text' , 'Some ' ) ,
@@ -40,7 +41,7 @@ test('findAndReplace', (t) => {
4041 'should work when given `find` and `replace`'
4142 )
4243
43- t . deepEqual (
44+ assert . deepEqual (
4445 findAndReplace (
4546 create ( ) ,
4647 / e m ( \w + ) i s / ,
@@ -58,7 +59,7 @@ test('findAndReplace', (t) => {
5859 'should work when given `find` as a `RegExp` and `replace` as a `Function`'
5960 )
6061
61- t . deepEqual (
62+ assert . deepEqual (
6263 findAndReplace ( create ( ) , 'emphasis' , ( ) => '' ) ,
6364 u ( 'paragraph' , [
6465 u ( 'text' , 'Some ' ) ,
@@ -72,7 +73,7 @@ test('findAndReplace', (t) => {
7273 'should work when given `replace` returns an empty string'
7374 )
7475
75- t . deepEqual (
76+ assert . deepEqual (
7677 findAndReplace ( create ( ) , 'emphasis' , ( ) => u ( 'delete' , [ u ( 'break' ) ] ) ) ,
7778 u ( 'paragraph' , [
7879 u ( 'text' , 'Some ' ) ,
@@ -86,7 +87,7 @@ test('findAndReplace', (t) => {
8687 'should work when given `replace` returns a node'
8788 )
8889
89- t . deepEqual (
90+ assert . deepEqual (
9091 findAndReplace ( create ( ) , 'emphasis' , ( ) => [ u ( 'delete' , [ ] ) , u ( 'break' ) ] ) ,
9192 u ( 'paragraph' , [
9293 u ( 'text' , 'Some ' ) ,
@@ -100,7 +101,7 @@ test('findAndReplace', (t) => {
100101 'should work when given `replace` returns a list of nodes'
101102 )
102103
103- t . deepEqual (
104+ assert . deepEqual (
104105 findAndReplace ( create ( ) , [
105106 [ 'emphasis' , '!!!' ] ,
106107 [ 'importance' , '???' ]
@@ -117,7 +118,7 @@ test('findAndReplace', (t) => {
117118 'should work when given `search` as an matrix of strings'
118119 )
119120
120- t . deepEqual (
121+ assert . deepEqual (
121122 findAndReplace ( create ( ) , { emp : 'hacks' , ',' : '!' } ) ,
122123 u ( 'paragraph' , [
123124 u ( 'text' , 'Some ' ) ,
@@ -133,7 +134,7 @@ test('findAndReplace', (t) => {
133134 'should work when given `search` as an object of strings'
134135 )
135136
136- t . deepEqual (
137+ assert . deepEqual (
137138 findAndReplace ( create ( ) , / \B m p \B / , '[MP]' ) ,
138139 u ( 'paragraph' , [
139140 u ( 'text' , 'Some ' ) ,
@@ -147,7 +148,7 @@ test('findAndReplace', (t) => {
147148 'should work on partial matches'
148149 )
149150
150- t . deepEqual (
151+ assert . deepEqual (
151152 findAndReplace ( create ( ) , {
152153 emphasis ( ) {
153154 return u ( 'link' , { url : 'x' } , [ u ( 'text' , 'importance' ) ] )
@@ -166,7 +167,7 @@ test('findAndReplace', (t) => {
166167 'should find-and-replace recursively'
167168 )
168169
169- t . deepEqual (
170+ assert . deepEqual (
170171 findAndReplace (
171172 u ( 'paragraph' , [
172173 u ( 'text' , 'Some ' ) ,
@@ -189,7 +190,7 @@ test('findAndReplace', (t) => {
189190 'should ignore from options'
190191 )
191192
192- t . deepEqual (
193+ assert . deepEqual (
193194 findAndReplace (
194195 u ( 'paragraph' , [ u ( 'text' , 'Some emphasis, importance, and code.' ) ] ) ,
195196 {
@@ -208,7 +209,7 @@ test('findAndReplace', (t) => {
208209 'should not be order-sensitive with strings'
209210 )
210211
211- t . deepEqual (
212+ assert . deepEqual (
212213 findAndReplace (
213214 u ( 'paragraph' , [ u ( 'text' , 'Some emphasis, importance, and code.' ) ] ) ,
214215 [
@@ -236,7 +237,7 @@ test('findAndReplace', (t) => {
236237 'should not be order-sensitive with regexes'
237238 )
238239
239- t . deepEqual (
240+ assert . deepEqual (
240241 findAndReplace ( u ( 'paragraph' , [ u ( 'text' , 'aaa bbb' ) ] ) , [
241242 [
242243 / \b \w + \b / g,
@@ -255,7 +256,7 @@ test('findAndReplace', (t) => {
255256 'should support a match, and then a `false`'
256257 )
257258
258- t . deepEqual (
259+ assert . deepEqual (
259260 findAndReplace ( create ( ) , 'emphasis' , ( ) => false ) ,
260261 u ( 'paragraph' , [
261262 u ( 'text' , 'Some ' ) ,
@@ -269,7 +270,7 @@ test('findAndReplace', (t) => {
269270 'should not replace when returning false'
270271 )
271272
272- t . deepEqual (
273+ assert . deepEqual (
273274 findAndReplace (
274275 u ( 'paragraph' , [ u ( 'text' , 'asd.' ) ] ) ,
275276 'asd' ,
@@ -279,7 +280,7 @@ test('findAndReplace', (t) => {
279280 'should not recurse into a replaced value'
280281 )
281282
282- t . deepEqual (
283+ assert . deepEqual (
283284 findAndReplace (
284285 u ( 'paragraph' , [ u ( 'text' , 'asd.' ) ] ) ,
285286 'asd' ,
@@ -289,7 +290,7 @@ test('findAndReplace', (t) => {
289290 'should not recurse into a replaced node (head)'
290291 )
291292
292- t . deepEqual (
293+ assert . deepEqual (
293294 findAndReplace (
294295 u ( 'paragraph' , [ u ( 'text' , '.asd' ) ] ) ,
295296 'asd' ,
@@ -299,7 +300,7 @@ test('findAndReplace', (t) => {
299300 'should not recurse into a replaced node (tail)'
300301 )
301302
302- t . deepEqual (
303+ assert . deepEqual (
303304 findAndReplace (
304305 u ( 'paragraph' , [ u ( 'text' , 'asd' ) ] ) ,
305306 'asd' ,
@@ -309,7 +310,7 @@ test('findAndReplace', (t) => {
309310 'should not recurse into a replaced node (head and tail)'
310311 )
311312
312- t . deepEqual (
313+ assert . deepEqual (
313314 findAndReplace ( create ( ) , 'and' , 'alert(1)' ) ,
314315 u ( 'paragraph' , [
315316 u ( 'text' , 'Some ' ) ,
@@ -324,8 +325,6 @@ test('findAndReplace', (t) => {
324325 ] ) ,
325326 'security: replacer as string (safe)'
326327 )
327-
328- t . end ( )
329328} )
330329
331330function create ( ) {
0 commit comments