4
4
* @typedef {Root['children'][number]|Root } Node
5
5
*/
6
6
7
- import assert from 'node:assert'
8
- import test from 'tape '
7
+ import assert from 'node:assert/strict '
8
+ import test from 'node:test '
9
9
import { fromMarkdown } from 'mdast-util-from-markdown'
10
10
import { VFile } from 'vfile'
11
11
import { source } from './index.js'
12
12
13
- test ( 'unist-util-source' , ( t ) => {
13
+ test ( 'unist-util-source' , ( ) => {
14
14
let file = new VFile ( '> + **[Hello](./example)**\n> world.' )
15
15
/** @type {Node } */
16
16
let node = fromMarkdown ( String ( file ) )
17
17
18
- t . equal ( source ( node , file ) , '> + **[Hello](./example)**\n> world.' , 'root' )
18
+ assert . equal (
19
+ source ( node , file ) ,
20
+ '> + **[Hello](./example)**\n> world.' ,
21
+ 'root'
22
+ )
19
23
20
24
assert ( node . type === 'root' )
21
25
node = node . children [ 0 ]
22
26
assert ( node . type === 'blockquote' )
23
- t . equal (
27
+ assert . equal (
24
28
source ( node , file ) ,
25
29
'> + **[Hello](./example)**\n> world.' ,
26
30
'block quote'
27
31
)
28
32
29
33
node = node . children [ 0 ]
30
34
assert ( node . type === 'list' )
31
- t . equal ( source ( node , file ) , '+ **[Hello](./example)**\n> world.' , 'list' )
35
+ assert . equal ( source ( node , file ) , '+ **[Hello](./example)**\n> world.' , 'list' )
32
36
33
37
node = node . children [ 0 ]
34
38
assert ( node . type === 'listItem' )
35
- t . equal ( source ( node , file ) , '+ **[Hello](./example)**\n> world.' , 'list item' )
39
+ assert . equal (
40
+ source ( node , file ) ,
41
+ '+ **[Hello](./example)**\n> world.' ,
42
+ 'list item'
43
+ )
36
44
37
45
node = node . children [ 0 ]
38
46
assert ( node . type === 'paragraph' )
39
- t . equal ( source ( node , file ) , '**[Hello](./example)**\n> world.' , 'paragraph' )
47
+ assert . equal (
48
+ source ( node , file ) ,
49
+ '**[Hello](./example)**\n> world.' ,
50
+ 'paragraph'
51
+ )
40
52
41
53
node = node . children [ 0 ]
42
54
assert ( node . type === 'strong' )
43
- t . equal ( source ( node , file ) , '**[Hello](./example)**' , 'strong' )
55
+ assert . equal ( source ( node , file ) , '**[Hello](./example)**' , 'strong' )
44
56
45
57
node = node . children [ 0 ]
46
58
assert ( node . type === 'link' )
47
- t . equal ( source ( node , file ) , '[Hello](./example)' , 'link' )
59
+ assert . equal ( source ( node , file ) , '[Hello](./example)' , 'link' )
48
60
49
61
node = node . children [ 0 ]
50
62
assert ( node . type === 'text' )
51
- t . equal ( source ( node , file ) , 'Hello' , 'text' )
63
+ assert . equal ( source ( node , file ) , 'Hello' , 'text' )
52
64
53
- t . equal ( source ( node . position , file ) , 'Hello' , 'position' )
65
+ assert . equal ( source ( node . position , file ) , 'Hello' , 'position' )
54
66
55
- t . equal (
67
+ assert . equal (
56
68
source (
57
69
/** @type {Text } */ ( {
58
70
type : 'text' ,
@@ -65,39 +77,37 @@ test('unist-util-source', (t) => {
65
77
'out of bounds data'
66
78
)
67
79
68
- t . equal (
80
+ assert . equal (
69
81
source ( /** @type {Text } */ ( { type : 'text' , value : 'qwe' } ) , file ) ,
70
82
null ,
71
83
'generated'
72
84
)
73
85
74
- t . equal ( source ( null , file ) , null , 'missing' )
86
+ assert . equal ( source ( null , file ) , null , 'missing' )
75
87
76
88
file = new VFile ( 'a\r\nb' )
77
89
node = fromMarkdown ( String ( file ) )
78
90
assert ( node . type === 'root' )
79
91
node = node . children [ 0 ]
80
92
assert ( node . type === 'paragraph' )
81
93
82
- t . equal ( source ( node , file ) , 'a\r\nb' , 'cr + lf' )
94
+ assert . equal ( source ( node , file ) , 'a\r\nb' , 'cr + lf' )
83
95
84
96
file = new VFile ( 'a\rb' )
85
97
node = fromMarkdown ( String ( file ) )
86
98
assert ( node . type === 'root' )
87
99
node = node . children [ 0 ]
88
100
assert ( node . type === 'paragraph' )
89
101
90
- t . equal ( source ( node , file ) , 'a\rb' , 'cr' )
102
+ assert . equal ( source ( node , file ) , 'a\rb' , 'cr' )
91
103
92
104
file = new VFile ( 'a\n' )
93
105
node = fromMarkdown ( String ( file ) )
94
106
95
- t . equal ( source ( node , file ) , 'a\n' , 'eof eol' )
107
+ assert . equal ( source ( node , file ) , 'a\n' , 'eof eol' )
96
108
97
109
file = new VFile ( 'a\n\rb' )
98
110
node = fromMarkdown ( String ( file ) )
99
111
100
- t . equal ( source ( node , file ) , 'a\n\rb' , 'blank lines' )
101
-
102
- t . end ( )
112
+ assert . equal ( source ( node , file ) , 'a\n\rb' , 'blank lines' )
103
113
} )
0 commit comments