1
- import test from 'tape'
1
+ import assert from 'node:assert/strict'
2
+ import test from 'node:test'
2
3
/* eslint-disable-next-line unicorn/import-style */
3
4
import { Chalk } from 'chalk'
4
5
import strip from 'strip-ansi'
@@ -13,14 +14,12 @@ const chalkEnabled = new Chalk({level: 1})
13
14
14
15
const paragraph = 'Some simple text. Other “sentence”.'
15
16
16
- test ( 'inspect' , ( t ) => {
17
- t . equal ( typeof inspect , 'function' , 'should be a `function`' )
18
-
19
- t . end ( )
17
+ test ( 'inspect' , ( ) => {
18
+ assert . equal ( typeof inspect , 'function' , 'should be a `function`' )
20
19
} )
21
20
22
- test ( 'inspect()' , ( t ) => {
23
- t . equal (
21
+ test ( 'inspect()' , ( ) => {
22
+ assert . equal (
24
23
strip ( inspect ( retext ( ) . parse ( paragraph ) ) ) ,
25
24
[
26
25
'RootNode[1] (1:1-1:36, 0-35)' ,
@@ -49,22 +48,20 @@ test('inspect()', (t) => {
49
48
'should work on `RootNode`'
50
49
)
51
50
52
- t . equal (
51
+ assert . equal (
53
52
strip ( inspect ( [ u ( 'SymbolNode' , '$' ) , u ( 'WordNode' , [ u ( 'text' , '5,00' ) ] ) ] ) ) ,
54
53
'├─0 SymbolNode "$"\n└─1 WordNode[1]\n └─0 text "5,00"' ,
55
54
'should work with a list of nodes'
56
55
)
57
56
58
- t . test ( 'should work on non-nodes' , ( st ) => {
59
- st . equal ( strip ( inspect ( 'foo' ) ) , '"foo"' )
60
- st . equal ( strip ( inspect ( null ) ) , 'null' )
61
- st . equal ( strip ( inspect ( Number . NaN ) ) , 'null' )
62
- st . equal ( strip ( inspect ( 3 ) ) , '3' )
63
-
64
- st . end ( )
65
- } )
57
+ assert . doesNotThrow ( ( ) => {
58
+ assert . equal ( strip ( inspect ( 'foo' ) ) , '"foo"' )
59
+ assert . equal ( strip ( inspect ( null ) ) , 'null' )
60
+ assert . equal ( strip ( inspect ( Number . NaN ) ) , 'null' )
61
+ assert . equal ( strip ( inspect ( 3 ) ) , '3' )
62
+ } , 'should work on non-nodes' )
66
63
67
- t . equal (
64
+ assert . equal (
68
65
strip (
69
66
inspect (
70
67
Array . from ( { length : 11 } ) . map ( ( /** @type {undefined } */ d , i ) => ( {
@@ -101,7 +98,7 @@ test('inspect()', (t) => {
101
98
'should align and indent large numbers'
102
99
)
103
100
104
- t . equal (
101
+ assert . equal (
105
102
strip (
106
103
inspect ( {
107
104
type : 'SymbolNode' ,
@@ -113,7 +110,7 @@ test('inspect()', (t) => {
113
110
'should work with data attributes'
114
111
)
115
112
116
- t . equal (
113
+ assert . equal (
117
114
strip (
118
115
inspect ( {
119
116
type : 'table' ,
@@ -165,7 +162,7 @@ test('inspect()', (t) => {
165
162
'should work with other attributes'
166
163
)
167
164
168
- t . equal (
165
+ assert . equal (
169
166
strip (
170
167
inspect ( {
171
168
type : 'element' ,
@@ -177,37 +174,37 @@ test('inspect()', (t) => {
177
174
'should work on parent nodes without children'
178
175
)
179
176
180
- t . equal (
177
+ assert . equal (
181
178
strip ( inspect ( { type : 'text' , value : '' } ) ) ,
182
179
'text ""' ,
183
180
'should work on text nodes without value'
184
181
)
185
182
186
- t . equal (
183
+ assert . equal (
187
184
strip ( inspect ( { type : 'thematicBreak' } ) ) ,
188
185
'thematicBreak' ,
189
186
'should work on void nodes'
190
187
)
191
188
192
- t . equal (
189
+ assert . equal (
193
190
strip ( inspect ( h ( 'button' , { type : 'submit' , value : 'Send' } ) ) ) ,
194
191
[
195
192
'element<button>[0]' ,
196
193
' properties: {"type":"submit","value":"Send"}'
197
194
] . join ( '\n' ) ,
198
195
'should see properties as data'
199
196
)
200
- t . equal (
197
+ assert . equal (
201
198
strip ( inspect ( x ( 'album' , { type : 'vinyl' , id : '123' } ) ) ) ,
202
199
'element<album>[0]\n attributes: {"type":"vinyl","id":"123"}' ,
203
200
'should see attributes as data'
204
201
)
205
- t . equal (
202
+ assert . equal (
206
203
strip ( inspect ( { type : 'node' , data : { type : 'notNode' } } ) ) ,
207
204
'node\n data: {"type":"notNode"}' ,
208
205
'should see data as data'
209
206
)
210
- t . equal (
207
+ assert . equal (
211
208
strip (
212
209
inspect (
213
210
u (
@@ -282,7 +279,7 @@ test('inspect()', (t) => {
282
279
'should handle nodes outside of children'
283
280
)
284
281
285
- t . equal (
282
+ assert . equal (
286
283
strip ( inspect ( fromXml ( '<album id="123" />' ) ) ) ,
287
284
[
288
285
'root[1]' ,
@@ -292,7 +289,7 @@ test('inspect()', (t) => {
292
289
'should work nodes of a certain kind (xast, hast)'
293
290
)
294
291
295
- t . equal (
292
+ assert . equal (
296
293
strip (
297
294
inspect ( {
298
295
type : 'foo' ,
@@ -307,7 +304,7 @@ test('inspect()', (t) => {
307
304
'should work without `offset` in `position`'
308
305
)
309
306
310
- t . equal (
307
+ assert . equal (
311
308
strip (
312
309
inspect ( {
313
310
type : 'foo' ,
@@ -319,7 +316,7 @@ test('inspect()', (t) => {
319
316
'should work without `start` and `end` in `position`'
320
317
)
321
318
322
- t . equal (
319
+ assert . equal (
323
320
strip (
324
321
inspect ( {
325
322
type : 'foo' ,
@@ -331,7 +328,7 @@ test('inspect()', (t) => {
331
328
'should work without `line` and `column` in `point`'
332
329
)
333
330
334
- t . equal (
331
+ assert . equal (
335
332
strip (
336
333
inspect ( {
337
334
type : 'foo' ,
@@ -346,7 +343,7 @@ test('inspect()', (t) => {
346
343
'should work with just `offset` in `position`'
347
344
)
348
345
349
- t . equal (
346
+ assert . equal (
350
347
strip ( inspect ( retext ( ) . parse ( paragraph ) , { showPositions : false } ) ) ,
351
348
[
352
349
'RootNode[1]' ,
@@ -374,12 +371,10 @@ test('inspect()', (t) => {
374
371
] . join ( '\n' ) ,
375
372
'should support `showPositions: false`'
376
373
)
377
-
378
- t . end ( )
379
374
} )
380
375
381
- test ( 'inspectNoColor()' , ( t ) => {
382
- t . equal (
376
+ test ( 'inspectNoColor()' , ( ) => {
377
+ assert . equal (
383
378
inspectNoColor ( retext ( ) . parse ( paragraph ) ) ,
384
379
[
385
380
'RootNode[1] (1:1-1:36, 0-35)\n└─0 ParagraphNode[3] (1:1-1:36, 0-35)' ,
@@ -406,12 +401,10 @@ test('inspectNoColor()', (t) => {
406
401
] . join ( '\n' ) ,
407
402
'should work'
408
403
)
409
-
410
- t . end ( )
411
404
} )
412
405
413
- test ( 'inspectColor()' , ( t ) => {
414
- t . equal (
406
+ test ( 'inspectColor()' , ( ) => {
407
+ assert . equal (
415
408
// @ts -expect-error: fine.
416
409
inspectColor ( retext ( ) . parse ( paragraph ) . children [ 0 ] . children [ 0 ] ) ,
417
410
[
@@ -516,6 +509,4 @@ test('inspectColor()', (t) => {
516
509
] . join ( '\n' ) ,
517
510
'should work'
518
511
)
519
-
520
- t . end ( )
521
512
} )
0 commit comments