Skip to content

Commit 011d649

Browse files
committed
Use Node test runner
1 parent 670a2fb commit 011d649

File tree

3 files changed

+51
-44
lines changed

3 files changed

+51
-44
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ jobs:
1717
strategy:
1818
matrix:
1919
node:
20-
- lts/fermium
20+
- lts/gallium
2121
- node

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"mdast-util-mdx-expression": "^1.1.0"
3838
},
3939
"devDependencies": {
40-
"@types/tape": "^4.0.0",
40+
"@types/node": "^18.0.0",
4141
"c8": "^7.0.0",
4242
"prettier": "^2.0.0",
4343
"remark-cli": "^11.0.0",

test.js

Lines changed: 49 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6,58 +6,59 @@
66
* @typedef {import('mdast-util-mdx-expression').MDXTextExpression} MDXTextExpression
77
*/
88

9-
import test from 'tape'
9+
import assert from 'node:assert/strict'
10+
import test from 'node:test'
1011
import {commentMarker} from './index.js'
1112

12-
test('commentMaker(node)', (t) => {
13+
test('commentMaker(node)', () => {
1314
// @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')
1516

1617
/** @type {Paragraph} */
1718
const paragraph = {type: 'paragraph', children: []}
1819

19-
t.equal(commentMarker(paragraph), null, 'should work without html node')
20+
assert.equal(commentMarker(paragraph), null, 'should work without html node')
2021

2122
/** @type {HTML} */
2223
let html = {type: 'html', value: '<div></div>'}
2324

24-
t.equal(commentMarker(html), null, 'should work without comment')
25+
assert.equal(commentMarker(html), null, 'should work without comment')
2526

2627
html = {type: 'html', value: '<!-- -->'}
2728

28-
t.equal(commentMarker(html), null, 'should work for empty comments')
29+
assert.equal(commentMarker(html), null, 'should work for empty comments')
2930

3031
html = {type: 'html', value: '<!--foo-->this is something else.'}
3132

32-
t.equal(commentMarker(html), null, 'should work for partial comments')
33+
assert.equal(commentMarker(html), null, 'should work for partial comments')
3334

3435
html = {type: 'html', value: '<!--foo-->'}
3536

36-
t.deepEqual(
37+
assert.deepEqual(
3738
commentMarker(html),
3839
{name: 'foo', attributes: '', parameters: {}, node: html},
3940
'marker without attributes'
4041
)
4142

4243
html = {type: 'html', value: '<!-- foo -->'}
4344

44-
t.deepEqual(
45+
assert.deepEqual(
4546
commentMarker(html),
4647
{name: 'foo', attributes: '', parameters: {}, node: html},
4748
'marker without attributes ignoring spaces'
4849
)
4950

5051
html = {type: 'html', value: '<!--foo bar-->'}
5152

52-
t.deepEqual(
53+
assert.deepEqual(
5354
commentMarker(html),
5455
{name: 'foo', attributes: 'bar', parameters: {bar: true}, node: html},
5556
'marker with boolean attributes'
5657
)
5758

5859
html = {type: 'html', value: '<!--foo bar=baz qux-->'}
5960

60-
t.deepEqual(
61+
assert.deepEqual(
6162
commentMarker(html),
6263
{
6364
name: 'foo',
@@ -70,7 +71,7 @@ test('commentMaker(node)', (t) => {
7071

7172
html = {type: 'html', value: '<!--foo bar="baz qux"-->'}
7273

73-
t.deepEqual(
74+
assert.deepEqual(
7475
commentMarker(html),
7576
{
7677
name: 'foo',
@@ -83,7 +84,7 @@ test('commentMaker(node)', (t) => {
8384

8485
html = {type: 'html', value: "<!--foo bar='baz qux'-->"}
8586

86-
t.deepEqual(
87+
assert.deepEqual(
8788
commentMarker(html),
8889
{
8990
name: 'foo',
@@ -96,7 +97,7 @@ test('commentMaker(node)', (t) => {
9697

9798
html = {type: 'html', value: '<!--foo bar=3-->'}
9899

99-
t.deepEqual(
100+
assert.deepEqual(
100101
commentMarker(html),
101102
{
102103
name: 'foo',
@@ -109,7 +110,7 @@ test('commentMaker(node)', (t) => {
109110

110111
html = {type: 'html', value: '<!--foo bar=true-->'}
111112

112-
t.deepEqual(
113+
assert.deepEqual(
113114
commentMarker(html),
114115
{
115116
name: 'foo',
@@ -122,7 +123,7 @@ test('commentMaker(node)', (t) => {
122123

123124
html = {type: 'html', value: '<!--foo bar=false-->'}
124125

125-
t.deepEqual(
126+
assert.deepEqual(
126127
commentMarker(html),
127128
{
128129
name: 'foo',
@@ -135,52 +136,62 @@ test('commentMaker(node)', (t) => {
135136

136137
html = {type: 'html', value: '<!--foo bar=-->'}
137138

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+
)
139144

140145
html = {type: 'html', value: '<!--foo bar= qux-->'}
141146

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+
)
143152

144153
html = {type: 'html', value: '<!--foo |-->'}
145154

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+
)
149160
})
150161

151-
test('comment node', (t) => {
162+
test('comment node', () => {
152163
/** @type {Literal & {type: 'comment'}} */
153164
let comment = {type: 'comment', value: ' '}
154165

155-
t.equal(commentMarker(comment), null, 'should work for empty comments')
166+
assert.equal(commentMarker(comment), null, 'should work for empty comments')
156167

157168
comment = {type: 'comment', value: 'foo'}
158169

159-
t.deepEqual(
170+
assert.deepEqual(
160171
commentMarker(comment),
161172
{name: 'foo', attributes: '', parameters: {}, node: comment},
162173
'comment without attributes'
163174
)
164175

165176
comment = {type: 'comment', value: ' foo '}
166177

167-
t.deepEqual(
178+
assert.deepEqual(
168179
commentMarker(comment),
169180
{name: 'foo', attributes: '', parameters: {}, node: comment},
170181
'comment without attributes ignoring spaces'
171182
)
172183

173184
comment = {type: 'comment', value: 'foo bar'}
174185

175-
t.deepEqual(
186+
assert.deepEqual(
176187
commentMarker(comment),
177188
{name: 'foo', attributes: 'bar', parameters: {bar: true}, node: comment},
178189
'comment with boolean attributes'
179190
)
180191

181192
comment = {type: 'comment', value: 'foo bar=baz qux'}
182193

183-
t.deepEqual(
194+
assert.deepEqual(
184195
commentMarker(comment),
185196
{
186197
name: 'foo',
@@ -193,7 +204,7 @@ test('comment node', (t) => {
193204

194205
comment = {type: 'comment', value: 'foo bar="baz qux"'}
195206

196-
t.deepEqual(
207+
assert.deepEqual(
197208
commentMarker(comment),
198209
{
199210
name: 'foo',
@@ -206,7 +217,7 @@ test('comment node', (t) => {
206217

207218
comment = {type: 'comment', value: "foo bar='baz qux'"}
208219

209-
t.deepEqual(
220+
assert.deepEqual(
210221
commentMarker(comment),
211222
{
212223
name: 'foo',
@@ -219,7 +230,7 @@ test('comment node', (t) => {
219230

220231
comment = {type: 'comment', value: 'foo bar=3'}
221232

222-
t.deepEqual(
233+
assert.deepEqual(
223234
commentMarker(comment),
224235
{
225236
name: 'foo',
@@ -232,7 +243,7 @@ test('comment node', (t) => {
232243

233244
comment = {type: 'comment', value: 'foo bar=true'}
234245

235-
t.deepEqual(
246+
assert.deepEqual(
236247
commentMarker(comment),
237248
{
238249
name: 'foo',
@@ -245,7 +256,7 @@ test('comment node', (t) => {
245256

246257
comment = {type: 'comment', value: 'foo bar=false'}
247258

248-
t.deepEqual(
259+
assert.deepEqual(
249260
commentMarker(comment),
250261
{
251262
name: 'foo',
@@ -258,39 +269,37 @@ test('comment node', (t) => {
258269

259270
comment = {type: 'comment', value: 'foo bar='}
260271

261-
t.equal(
272+
assert.equal(
262273
commentMarker(comment),
263274
null,
264275
'marker stop for invalid parameters (#1)'
265276
)
266277

267278
comment = {type: 'comment', value: 'foo bar= qux'}
268279

269-
t.equal(
280+
assert.equal(
270281
commentMarker(comment),
271282
null,
272283
'marker stop for invalid parameters (#2)'
273284
)
274285

275286
comment = {type: 'comment', value: 'foo |'}
276287

277-
t.equal(
288+
assert.equal(
278289
commentMarker(comment),
279290
null,
280291
'marker stop for invalid parameters (#3)'
281292
)
282-
283-
t.end()
284293
})
285294

286-
test('MDX@2 expressions', (t) => {
295+
test('MDX@2 expressions', () => {
287296
/** @type {MDXFlowExpression|MDXTextExpression} */
288297
let node = {
289298
type: 'mdxFlowExpression',
290299
value: '/* lint disable heading-style */'
291300
}
292301

293-
t.deepEqual(
302+
assert.deepEqual(
294303
commentMarker(node),
295304
{
296305
name: 'lint',
@@ -303,11 +312,9 @@ test('MDX@2 expressions', (t) => {
303312

304313
node = {type: 'mdxTextExpression', value: '/* lint enable */'}
305314

306-
t.deepEqual(
315+
assert.deepEqual(
307316
commentMarker(node),
308317
{name: 'lint', attributes: 'enable', parameters: {enable: true}, node},
309318
'should work for comments'
310319
)
311-
312-
t.end()
313320
})

0 commit comments

Comments
 (0)