Skip to content

Commit 8901d8b

Browse files
committed
Use Node test runner
1 parent 22b9c44 commit 8901d8b

File tree

3 files changed

+35
-45
lines changed

3 files changed

+35
-45
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 & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"@types/unist": "^2.0.0"
4343
},
4444
"devDependencies": {
45-
"@types/tape": "^4.0.0",
45+
"@types/node": "^18.0.0",
4646
"c8": "^7.0.0",
4747
"chalk": "^5.0.0",
4848
"hastscript": "^7.0.0",
@@ -51,7 +51,6 @@
5151
"remark-preset-wooorm": "^9.0.0",
5252
"retext": "^8.0.0",
5353
"strip-ansi": "^7.0.0",
54-
"tape": "^5.0.0",
5554
"type-coverage": "^2.0.0",
5655
"typescript": "^4.0.0",
5756
"unist-builder": "^3.0.0",

test.js

Lines changed: 33 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import test from 'tape'
1+
import assert from 'node:assert/strict'
2+
import test from 'node:test'
23
/* eslint-disable-next-line unicorn/import-style */
34
import {Chalk} from 'chalk'
45
import strip from 'strip-ansi'
@@ -13,14 +14,12 @@ const chalkEnabled = new Chalk({level: 1})
1314

1415
const paragraph = 'Some simple text. Other “sentence”.'
1516

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`')
2019
})
2120

22-
test('inspect()', (t) => {
23-
t.equal(
21+
test('inspect()', () => {
22+
assert.equal(
2423
strip(inspect(retext().parse(paragraph))),
2524
[
2625
'RootNode[1] (1:1-1:36, 0-35)',
@@ -49,22 +48,20 @@ test('inspect()', (t) => {
4948
'should work on `RootNode`'
5049
)
5150

52-
t.equal(
51+
assert.equal(
5352
strip(inspect([u('SymbolNode', '$'), u('WordNode', [u('text', '5,00')])])),
5453
'├─0 SymbolNode "$"\n└─1 WordNode[1]\n └─0 text "5,00"',
5554
'should work with a list of nodes'
5655
)
5756

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')
6663

67-
t.equal(
64+
assert.equal(
6865
strip(
6966
inspect(
7067
Array.from({length: 11}).map((/** @type {undefined} */ d, i) => ({
@@ -101,7 +98,7 @@ test('inspect()', (t) => {
10198
'should align and indent large numbers'
10299
)
103100

104-
t.equal(
101+
assert.equal(
105102
strip(
106103
inspect({
107104
type: 'SymbolNode',
@@ -113,7 +110,7 @@ test('inspect()', (t) => {
113110
'should work with data attributes'
114111
)
115112

116-
t.equal(
113+
assert.equal(
117114
strip(
118115
inspect({
119116
type: 'table',
@@ -165,7 +162,7 @@ test('inspect()', (t) => {
165162
'should work with other attributes'
166163
)
167164

168-
t.equal(
165+
assert.equal(
169166
strip(
170167
inspect({
171168
type: 'element',
@@ -177,37 +174,37 @@ test('inspect()', (t) => {
177174
'should work on parent nodes without children'
178175
)
179176

180-
t.equal(
177+
assert.equal(
181178
strip(inspect({type: 'text', value: ''})),
182179
'text ""',
183180
'should work on text nodes without value'
184181
)
185182

186-
t.equal(
183+
assert.equal(
187184
strip(inspect({type: 'thematicBreak'})),
188185
'thematicBreak',
189186
'should work on void nodes'
190187
)
191188

192-
t.equal(
189+
assert.equal(
193190
strip(inspect(h('button', {type: 'submit', value: 'Send'}))),
194191
[
195192
'element<button>[0]',
196193
' properties: {"type":"submit","value":"Send"}'
197194
].join('\n'),
198195
'should see properties as data'
199196
)
200-
t.equal(
197+
assert.equal(
201198
strip(inspect(x('album', {type: 'vinyl', id: '123'}))),
202199
'element<album>[0]\n attributes: {"type":"vinyl","id":"123"}',
203200
'should see attributes as data'
204201
)
205-
t.equal(
202+
assert.equal(
206203
strip(inspect({type: 'node', data: {type: 'notNode'}})),
207204
'node\n data: {"type":"notNode"}',
208205
'should see data as data'
209206
)
210-
t.equal(
207+
assert.equal(
211208
strip(
212209
inspect(
213210
u(
@@ -282,7 +279,7 @@ test('inspect()', (t) => {
282279
'should handle nodes outside of children'
283280
)
284281

285-
t.equal(
282+
assert.equal(
286283
strip(inspect(fromXml('<album id="123" />'))),
287284
[
288285
'root[1]',
@@ -292,7 +289,7 @@ test('inspect()', (t) => {
292289
'should work nodes of a certain kind (xast, hast)'
293290
)
294291

295-
t.equal(
292+
assert.equal(
296293
strip(
297294
inspect({
298295
type: 'foo',
@@ -307,7 +304,7 @@ test('inspect()', (t) => {
307304
'should work without `offset` in `position`'
308305
)
309306

310-
t.equal(
307+
assert.equal(
311308
strip(
312309
inspect({
313310
type: 'foo',
@@ -319,7 +316,7 @@ test('inspect()', (t) => {
319316
'should work without `start` and `end` in `position`'
320317
)
321318

322-
t.equal(
319+
assert.equal(
323320
strip(
324321
inspect({
325322
type: 'foo',
@@ -331,7 +328,7 @@ test('inspect()', (t) => {
331328
'should work without `line` and `column` in `point`'
332329
)
333330

334-
t.equal(
331+
assert.equal(
335332
strip(
336333
inspect({
337334
type: 'foo',
@@ -346,7 +343,7 @@ test('inspect()', (t) => {
346343
'should work with just `offset` in `position`'
347344
)
348345

349-
t.equal(
346+
assert.equal(
350347
strip(inspect(retext().parse(paragraph), {showPositions: false})),
351348
[
352349
'RootNode[1]',
@@ -374,12 +371,10 @@ test('inspect()', (t) => {
374371
].join('\n'),
375372
'should support `showPositions: false`'
376373
)
377-
378-
t.end()
379374
})
380375

381-
test('inspectNoColor()', (t) => {
382-
t.equal(
376+
test('inspectNoColor()', () => {
377+
assert.equal(
383378
inspectNoColor(retext().parse(paragraph)),
384379
[
385380
'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) => {
406401
].join('\n'),
407402
'should work'
408403
)
409-
410-
t.end()
411404
})
412405

413-
test('inspectColor()', (t) => {
414-
t.equal(
406+
test('inspectColor()', () => {
407+
assert.equal(
415408
// @ts-expect-error: fine.
416409
inspectColor(retext().parse(paragraph).children[0].children[0]),
417410
[
@@ -516,6 +509,4 @@ test('inspectColor()', (t) => {
516509
].join('\n'),
517510
'should work'
518511
)
519-
520-
t.end()
521512
})

0 commit comments

Comments
 (0)