5
5
*/
6
6
7
7
import assert from 'node:assert/strict'
8
- import test from 'tape '
8
+ import test from 'node:test '
9
9
import { fromMarkdown } from 'mdast-util-from-markdown'
10
10
import { toMarkdown } from 'mdast-util-to-markdown'
11
11
import { headingRange } from './index.js'
12
12
13
- test ( 'mdast-util-heading-range()' , ( t ) => {
14
- t . plan ( 21 )
13
+ test ( 'mdast-util-heading-range()' , ( ) => {
14
+ assert . equal ( typeof headingRange , 'function' , 'should be a function' )
15
15
16
- t . equal ( typeof headingRange , 'function' , 'should be a function' )
17
-
18
- t . throws (
16
+ assert . throws (
19
17
( ) => {
20
18
headingRange (
21
19
/** @type {Root } */ ( { type : 'root' , children : [ ] } ) ,
@@ -28,7 +26,7 @@ test('mdast-util-heading-range()', (t) => {
28
26
'should throw when `null` is passed in'
29
27
)
30
28
31
- t . throws (
29
+ assert . throws (
32
30
( ) => {
33
31
headingRange (
34
32
/** @type {Root } */ ( { type : 'root' , children : [ ] } ) ,
@@ -41,11 +39,11 @@ test('mdast-util-heading-range()', (t) => {
41
39
'should throw when `undefined` is passed in'
42
40
)
43
41
44
- t . doesNotThrow ( ( ) => {
42
+ assert . doesNotThrow ( ( ) => {
45
43
headingRange ( /** @type {Root } */ ( { type : 'root' } ) , 'x' , ( ) => { } )
46
44
} , 'should not throw when a non-parent is passed' )
47
45
48
- t . equal (
46
+ assert . equal (
49
47
checkAndRemove (
50
48
[ '# Fo' , '' , '## Fooooo' , '' , 'Bar' , '' , '# Fo' , '' ] . join ( '\n' ) ,
51
49
'foo+'
@@ -54,7 +52,7 @@ test('mdast-util-heading-range()', (t) => {
54
52
'should accept a heading as string'
55
53
)
56
54
57
- t . equal (
55
+ assert . equal (
58
56
checkAndRemove (
59
57
[ '# Fo' , '' , '## Fooooo' , '' , 'Bar' , '' , '# Fo' , '' ] . join ( '\n' ) ,
60
58
/ f o o + / i
@@ -63,7 +61,7 @@ test('mdast-util-heading-range()', (t) => {
63
61
'should accept a heading as a regex'
64
62
)
65
63
66
- t . equal (
64
+ assert . equal (
67
65
checkAndRemove (
68
66
[ '# Fo' , '' , '## Fooooo' , '' , 'Bar' , '' , '# Fo' , '' ] . join ( '\n' ) ,
69
67
( value ) => value . toLowerCase ( ) . indexOf ( 'foo' ) === 0
@@ -72,13 +70,13 @@ test('mdast-util-heading-range()', (t) => {
72
70
'should accept a heading as a function'
73
71
)
74
72
75
- t . equal (
73
+ assert . equal (
76
74
checkAndRemove ( [ '# Fo' , '' , '## Fooooo' , '' , 'Bar' , '' ] . join ( '\n' ) , 'foo+' ) ,
77
75
[ '# Fo' , '' , '## Fooooo' , '' ] . join ( '\n' ) ,
78
76
'should accept a missing closing heading'
79
77
)
80
78
81
- t . equal (
79
+ assert . equal (
82
80
checkAndRemove (
83
81
[ '# Fo' , '' , '## ' , '' , 'Bar' , '' , '# Fo' , '' ] . join ( '\n' ) ,
84
82
'foo+'
@@ -87,7 +85,7 @@ test('mdast-util-heading-range()', (t) => {
87
85
'should accept images'
88
86
)
89
87
90
- t . equal (
88
+ assert . equal (
91
89
checkAndRemove (
92
90
[ '# Fo' , '' , '## [Foo](bar.com)' , '' , 'Bar' , '' , '# Fo' , '' ] . join ( '\n' ) ,
93
91
'foo+'
@@ -96,7 +94,7 @@ test('mdast-util-heading-range()', (t) => {
96
94
'should accept links'
97
95
)
98
96
99
- t . equal (
97
+ assert . equal (
100
98
checkAndRemove (
101
99
[
102
100
'# Fo' ,
@@ -114,13 +112,13 @@ test('mdast-util-heading-range()', (t) => {
114
112
'should accept an image in a link'
115
113
)
116
114
117
- t . equal (
115
+ assert . equal (
118
116
checkAndRemove ( [ '# Fo' , '' , '## Bar' , '' , 'Baz' , '' ] . join ( '\n' ) , 'foo+' ) ,
119
117
[ '# Fo' , '' , '## Bar' , '' , 'Baz' , '' ] . join ( '\n' ) ,
120
118
'should not fail without heading'
121
119
)
122
120
123
- t . equal (
121
+ assert . equal (
124
122
checkAndRemove (
125
123
[ '# ' , '' , '## Foo' , '' , 'Bar' , '' , '## Baz' , '' ] . join ( '\n' ) ,
126
124
'fo+'
@@ -131,7 +129,7 @@ test('mdast-util-heading-range()', (t) => {
131
129
132
130
const treeNull = fromMarkdown ( [ 'Foo' , '' , '## Foo' , '' , 'Bar' , '' ] . join ( '\n' ) )
133
131
headingRange ( treeNull , 'foo' , ( ) => null )
134
- t . equal (
132
+ assert . equal (
135
133
toMarkdown ( treeNull ) ,
136
134
[ 'Foo' , '' , '## Foo' , '' , 'Bar' , '' ] . join ( '\n' ) ,
137
135
'should not remove anything when `null` is given'
@@ -141,7 +139,7 @@ test('mdast-util-heading-range()', (t) => {
141
139
[ 'Foo' , '' , '## Foo' , '' , 'Bar' , '' ] . join ( '\n' )
142
140
)
143
141
headingRange ( treeEmpty , 'foo' , ( ) => [ ] )
144
- t . equal (
142
+ assert . equal (
145
143
toMarkdown ( treeEmpty ) ,
146
144
[ 'Foo' , '' ] . join ( '\n' ) ,
147
145
'should replace all previous nodes otherwise'
@@ -155,7 +153,7 @@ test('mdast-util-heading-range()', (t) => {
155
153
{ type : 'thematicBreak' } ,
156
154
end
157
155
] )
158
- t . equal (
156
+ assert . equal (
159
157
toMarkdown ( treeFilled ) ,
160
158
[ 'Foo' , '' , '## Foo' , '' , '***' , '' , '## Baz' , '' ] . join ( '\n' ) ,
161
159
'should insert all returned nodes'
@@ -165,16 +163,16 @@ test('mdast-util-heading-range()', (t) => {
165
163
[ '# Alpha' , '' , '## Foo' , '' , 'one' , '' , 'two' , '' , 'three' , '' ] . join ( '\n' )
166
164
)
167
165
headingRange ( treeEmptyEnd , 'foo' , ( start , nodes , end ) => {
168
- t . equal ( nodes . length , 3 )
166
+ assert . equal ( nodes . length , 3 )
169
167
return [ start , ...nodes , end ]
170
168
} )
171
- t . equal (
169
+ assert . equal (
172
170
toMarkdown ( treeEmptyEnd ) ,
173
171
[ '# Alpha' , '' , '## Foo' , '' , 'one' , '' , 'two' , '' , 'three' , '' ] . join ( '\n' ) ,
174
172
'should not insert an empty `end`'
175
173
)
176
174
177
- t . equal (
175
+ assert . equal (
178
176
checkAndRemove (
179
177
[
180
178
'# Fo' ,
@@ -207,7 +205,7 @@ test('mdast-util-heading-range()', (t) => {
207
205
'ignoreFinalDefinitions: should exclude definitions with an end heading'
208
206
)
209
207
210
- t . equal (
208
+ assert . equal (
211
209
checkAndRemove (
212
210
[
213
211
'# Fo' ,
@@ -238,7 +236,7 @@ test('mdast-util-heading-range()', (t) => {
238
236
'ignoreFinalDefinitions: should exclude only definitions'
239
237
)
240
238
241
- t . equal (
239
+ assert . equal (
242
240
checkAndRemove (
243
241
[
244
242
'# Fo' ,
0 commit comments