6
6
* @typedef {import('mdast-util-mdx-expression').MDXTextExpression } MDXTextExpression
7
7
*/
8
8
9
- import test from 'tape'
9
+ import assert from 'node:assert/strict'
10
+ import test from 'node:test'
10
11
import { commentMarker } from './index.js'
11
12
12
- test ( 'commentMaker(node)' , ( t ) => {
13
+ test ( 'commentMaker(node)' , ( ) => {
13
14
// @ts -expect-error: runtime: not enough arguments.
14
- t . equal ( commentMarker ( ) , null , 'should work without node' )
15
+ assert . equal ( commentMarker ( ) , null , 'should work without node' )
15
16
16
17
/** @type {Paragraph } */
17
18
const paragraph = { type : 'paragraph' , children : [ ] }
18
19
19
- t . equal ( commentMarker ( paragraph ) , null , 'should work without html node' )
20
+ assert . equal ( commentMarker ( paragraph ) , null , 'should work without html node' )
20
21
21
22
/** @type {HTML } */
22
23
let html = { type : 'html' , value : '<div></div>' }
23
24
24
- t . equal ( commentMarker ( html ) , null , 'should work without comment' )
25
+ assert . equal ( commentMarker ( html ) , null , 'should work without comment' )
25
26
26
27
html = { type : 'html' , value : '<!-- -->' }
27
28
28
- t . equal ( commentMarker ( html ) , null , 'should work for empty comments' )
29
+ assert . equal ( commentMarker ( html ) , null , 'should work for empty comments' )
29
30
30
31
html = { type : 'html' , value : '<!--foo-->this is something else.' }
31
32
32
- t . equal ( commentMarker ( html ) , null , 'should work for partial comments' )
33
+ assert . equal ( commentMarker ( html ) , null , 'should work for partial comments' )
33
34
34
35
html = { type : 'html' , value : '<!--foo-->' }
35
36
36
- t . deepEqual (
37
+ assert . deepEqual (
37
38
commentMarker ( html ) ,
38
39
{ name : 'foo' , attributes : '' , parameters : { } , node : html } ,
39
40
'marker without attributes'
40
41
)
41
42
42
43
html = { type : 'html' , value : '<!-- foo -->' }
43
44
44
- t . deepEqual (
45
+ assert . deepEqual (
45
46
commentMarker ( html ) ,
46
47
{ name : 'foo' , attributes : '' , parameters : { } , node : html } ,
47
48
'marker without attributes ignoring spaces'
48
49
)
49
50
50
51
html = { type : 'html' , value : '<!--foo bar-->' }
51
52
52
- t . deepEqual (
53
+ assert . deepEqual (
53
54
commentMarker ( html ) ,
54
55
{ name : 'foo' , attributes : 'bar' , parameters : { bar : true } , node : html } ,
55
56
'marker with boolean attributes'
56
57
)
57
58
58
59
html = { type : 'html' , value : '<!--foo bar=baz qux-->' }
59
60
60
- t . deepEqual (
61
+ assert . deepEqual (
61
62
commentMarker ( html ) ,
62
63
{
63
64
name : 'foo' ,
@@ -70,7 +71,7 @@ test('commentMaker(node)', (t) => {
70
71
71
72
html = { type : 'html' , value : '<!--foo bar="baz qux"-->' }
72
73
73
- t . deepEqual (
74
+ assert . deepEqual (
74
75
commentMarker ( html ) ,
75
76
{
76
77
name : 'foo' ,
@@ -83,7 +84,7 @@ test('commentMaker(node)', (t) => {
83
84
84
85
html = { type : 'html' , value : "<!--foo bar='baz qux'-->" }
85
86
86
- t . deepEqual (
87
+ assert . deepEqual (
87
88
commentMarker ( html ) ,
88
89
{
89
90
name : 'foo' ,
@@ -96,7 +97,7 @@ test('commentMaker(node)', (t) => {
96
97
97
98
html = { type : 'html' , value : '<!--foo bar=3-->' }
98
99
99
- t . deepEqual (
100
+ assert . deepEqual (
100
101
commentMarker ( html ) ,
101
102
{
102
103
name : 'foo' ,
@@ -109,7 +110,7 @@ test('commentMaker(node)', (t) => {
109
110
110
111
html = { type : 'html' , value : '<!--foo bar=true-->' }
111
112
112
- t . deepEqual (
113
+ assert . deepEqual (
113
114
commentMarker ( html ) ,
114
115
{
115
116
name : 'foo' ,
@@ -122,7 +123,7 @@ test('commentMaker(node)', (t) => {
122
123
123
124
html = { type : 'html' , value : '<!--foo bar=false-->' }
124
125
125
- t . deepEqual (
126
+ assert . deepEqual (
126
127
commentMarker ( html ) ,
127
128
{
128
129
name : 'foo' ,
@@ -135,52 +136,62 @@ test('commentMaker(node)', (t) => {
135
136
136
137
html = { type : 'html' , value : '<!--foo bar=-->' }
137
138
138
- t . equal ( commentMarker ( html ) , null , 'marker stop for invalid parameters (#1)' )
139
+ assert . equal (
140
+ commentMarker ( html ) ,
141
+ null ,
142
+ 'marker stop for invalid parameters (#1)'
143
+ )
139
144
140
145
html = { type : 'html' , value : '<!--foo bar= qux-->' }
141
146
142
- t . equal ( commentMarker ( html ) , null , 'marker stop for invalid parameters (#2)' )
147
+ assert . equal (
148
+ commentMarker ( html ) ,
149
+ null ,
150
+ 'marker stop for invalid parameters (#2)'
151
+ )
143
152
144
153
html = { type : 'html' , value : '<!--foo |-->' }
145
154
146
- t . equal ( commentMarker ( html ) , null , 'marker stop for invalid parameters (#3)' )
147
-
148
- t . end ( )
155
+ assert . equal (
156
+ commentMarker ( html ) ,
157
+ null ,
158
+ 'marker stop for invalid parameters (#3)'
159
+ )
149
160
} )
150
161
151
- test ( 'comment node' , ( t ) => {
162
+ test ( 'comment node' , ( ) => {
152
163
/** @type {Literal & {type: 'comment'} } */
153
164
let comment = { type : 'comment' , value : ' ' }
154
165
155
- t . equal ( commentMarker ( comment ) , null , 'should work for empty comments' )
166
+ assert . equal ( commentMarker ( comment ) , null , 'should work for empty comments' )
156
167
157
168
comment = { type : 'comment' , value : 'foo' }
158
169
159
- t . deepEqual (
170
+ assert . deepEqual (
160
171
commentMarker ( comment ) ,
161
172
{ name : 'foo' , attributes : '' , parameters : { } , node : comment } ,
162
173
'comment without attributes'
163
174
)
164
175
165
176
comment = { type : 'comment' , value : ' foo ' }
166
177
167
- t . deepEqual (
178
+ assert . deepEqual (
168
179
commentMarker ( comment ) ,
169
180
{ name : 'foo' , attributes : '' , parameters : { } , node : comment } ,
170
181
'comment without attributes ignoring spaces'
171
182
)
172
183
173
184
comment = { type : 'comment' , value : 'foo bar' }
174
185
175
- t . deepEqual (
186
+ assert . deepEqual (
176
187
commentMarker ( comment ) ,
177
188
{ name : 'foo' , attributes : 'bar' , parameters : { bar : true } , node : comment } ,
178
189
'comment with boolean attributes'
179
190
)
180
191
181
192
comment = { type : 'comment' , value : 'foo bar=baz qux' }
182
193
183
- t . deepEqual (
194
+ assert . deepEqual (
184
195
commentMarker ( comment ) ,
185
196
{
186
197
name : 'foo' ,
@@ -193,7 +204,7 @@ test('comment node', (t) => {
193
204
194
205
comment = { type : 'comment' , value : 'foo bar="baz qux"' }
195
206
196
- t . deepEqual (
207
+ assert . deepEqual (
197
208
commentMarker ( comment ) ,
198
209
{
199
210
name : 'foo' ,
@@ -206,7 +217,7 @@ test('comment node', (t) => {
206
217
207
218
comment = { type : 'comment' , value : "foo bar='baz qux'" }
208
219
209
- t . deepEqual (
220
+ assert . deepEqual (
210
221
commentMarker ( comment ) ,
211
222
{
212
223
name : 'foo' ,
@@ -219,7 +230,7 @@ test('comment node', (t) => {
219
230
220
231
comment = { type : 'comment' , value : 'foo bar=3' }
221
232
222
- t . deepEqual (
233
+ assert . deepEqual (
223
234
commentMarker ( comment ) ,
224
235
{
225
236
name : 'foo' ,
@@ -232,7 +243,7 @@ test('comment node', (t) => {
232
243
233
244
comment = { type : 'comment' , value : 'foo bar=true' }
234
245
235
- t . deepEqual (
246
+ assert . deepEqual (
236
247
commentMarker ( comment ) ,
237
248
{
238
249
name : 'foo' ,
@@ -245,7 +256,7 @@ test('comment node', (t) => {
245
256
246
257
comment = { type : 'comment' , value : 'foo bar=false' }
247
258
248
- t . deepEqual (
259
+ assert . deepEqual (
249
260
commentMarker ( comment ) ,
250
261
{
251
262
name : 'foo' ,
@@ -258,39 +269,37 @@ test('comment node', (t) => {
258
269
259
270
comment = { type : 'comment' , value : 'foo bar=' }
260
271
261
- t . equal (
272
+ assert . equal (
262
273
commentMarker ( comment ) ,
263
274
null ,
264
275
'marker stop for invalid parameters (#1)'
265
276
)
266
277
267
278
comment = { type : 'comment' , value : 'foo bar= qux' }
268
279
269
- t . equal (
280
+ assert . equal (
270
281
commentMarker ( comment ) ,
271
282
null ,
272
283
'marker stop for invalid parameters (#2)'
273
284
)
274
285
275
286
comment = { type : 'comment' , value : 'foo |' }
276
287
277
- t . equal (
288
+ assert . equal (
278
289
commentMarker ( comment ) ,
279
290
null ,
280
291
'marker stop for invalid parameters (#3)'
281
292
)
282
-
283
- t . end ( )
284
293
} )
285
294
286
- test ( 'MDX@2 expressions' , ( t ) => {
295
+ test ( 'MDX@2 expressions' , ( ) => {
287
296
/** @type {MDXFlowExpression|MDXTextExpression } */
288
297
let node = {
289
298
type : 'mdxFlowExpression' ,
290
299
value : '/* lint disable heading-style */'
291
300
}
292
301
293
- t . deepEqual (
302
+ assert . deepEqual (
294
303
commentMarker ( node ) ,
295
304
{
296
305
name : 'lint' ,
@@ -303,11 +312,9 @@ test('MDX@2 expressions', (t) => {
303
312
304
313
node = { type : 'mdxTextExpression' , value : '/* lint enable */' }
305
314
306
- t . deepEqual (
315
+ assert . deepEqual (
307
316
commentMarker ( node ) ,
308
317
{ name : 'lint' , attributes : 'enable' , parameters : { enable : true } , node} ,
309
318
'should work for comments'
310
319
)
311
-
312
- t . end ( )
313
320
} )
0 commit comments