Skip to content

Commit 8afd67c

Browse files
committed
Use Node test runner
1 parent 10f9cf0 commit 8afd67c

File tree

3 files changed

+52
-74
lines changed

3 files changed

+52
-74
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/hydrogen
2121
- node

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,13 @@
4646
"zwitch": "^2.0.0"
4747
},
4848
"devDependencies": {
49-
"@types/tape": "^4.0.0",
49+
"@types/node": "^18.0.0",
5050
"c8": "^7.0.0",
5151
"hastscript": "^7.0.0",
5252
"prettier": "^2.0.0",
5353
"remark-cli": "^11.0.0",
5454
"remark-preset-wooorm": "^9.0.0",
5555
"rimraf": "^3.0.0",
56-
"tape": "^5.0.0",
5756
"type-coverage": "^2.0.0",
5857
"typescript": "^4.0.0",
5958
"unist-builder": "^3.0.0",

test.js

Lines changed: 50 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
import test from 'tape'
1+
import assert from 'node:assert/strict'
2+
import test from 'node:test'
23
import {webNamespaces as ns} from 'web-namespaces'
34
import {u} from 'unist-builder'
45
import {h, s} from 'hastscript'
56
import {x} from 'xastscript'
67
import {toXast} from './index.js'
78

8-
test('toXast', (t) => {
9-
t.test('main', (t) => {
10-
t.equal(typeof toXast, 'function', 'should expose a function')
9+
test('toXast', async (t) => {
10+
await t.test('main', () => {
11+
assert.equal(typeof toXast, 'function', 'should expose a function')
1112

12-
t.throws(
13+
assert.throws(
1314
() => {
1415
// @ts-expect-error runtime.
1516
toXast()
@@ -18,7 +19,7 @@ test('toXast', (t) => {
1819
'should throw without node'
1920
)
2021

21-
t.throws(
22+
assert.throws(
2223
() => {
2324
// @ts-expect-error well-known.
2425
toXast({type: 'raw', value: '<script>alert(1)</script>'})
@@ -27,25 +28,25 @@ test('toXast', (t) => {
2728
'should throw if a node cannot be handled'
2829
)
2930

30-
t.deepEqual(
31+
assert.deepEqual(
3132
toXast(h('div')),
3233
x('div', {xmlns: ns.html}),
3334
'should support html'
3435
)
3536

36-
t.deepEqual(
37+
assert.deepEqual(
3738
toXast(s('rect'), {space: 'svg'}),
3839
x('rect', {xmlns: ns.svg}),
3940
'should support `options.space` (svg)'
4041
)
4142

42-
t.deepEqual(
43+
assert.deepEqual(
4344
toXast(s('circle'), 'svg'),
4445
x('circle', {xmlns: ns.svg}),
4546
'should support `space` (svg)'
4647
)
4748

48-
t.deepEqual(
49+
assert.deepEqual(
4950
toXast({
5051
type: 'text',
5152
value: 'foo',
@@ -64,73 +65,63 @@ test('toXast', (t) => {
6465
},
6566
'should support positional information'
6667
)
67-
68-
t.end()
6968
})
7069

71-
t.test('root', (t) => {
72-
t.deepEqual(
70+
await t.test('root', () => {
71+
assert.deepEqual(
7372
toXast(u('root', [h('div', 'Alpha')])),
7473
u('root', [x('div', {xmlns: ns.html}, 'Alpha')]),
7574
'should support a root node'
7675
)
77-
78-
t.end()
7976
})
8077

81-
t.test('text', (t) => {
82-
t.deepEqual(
78+
await t.test('text', () => {
79+
assert.deepEqual(
8380
toXast(u('text', 'Alpha')),
8481
u('text', 'Alpha'),
8582
'should support a text node'
8683
)
8784

88-
t.deepEqual(
85+
assert.deepEqual(
8986
// @ts-expect-error runtime.
9087
toXast(u('text')),
9188
u('text', ''),
9289
'should support a void text node'
9390
)
94-
95-
t.end()
9691
})
9792

98-
t.test('comment', (t) => {
99-
t.deepEqual(
93+
await t.test('comment', () => {
94+
assert.deepEqual(
10095
toXast(u('comment', 'Alpha')),
10196
u('comment', 'Alpha'),
10297
'should support a comment node'
10398
)
10499

105-
t.deepEqual(
100+
assert.deepEqual(
106101
// @ts-expect-error runtime.
107102
toXast(u('comment')),
108103
u('comment', ''),
109104
'should support a void comment node'
110105
)
111-
112-
t.end()
113106
})
114107

115-
t.test('doctype', (t) => {
116-
t.deepEqual(
108+
await t.test('doctype', () => {
109+
assert.deepEqual(
117110
// @ts-expect-error hast@next.
118111
toXast(u('doctype')),
119112
u('doctype', {name: 'html', public: undefined, system: undefined}),
120113
'should support a doctype node'
121114
)
122-
123-
t.end()
124115
})
125116

126-
t.test('element', (t) => {
127-
t.deepEqual(
117+
await t.test('element', () => {
118+
assert.deepEqual(
128119
toXast(h('p', [h('a', 'A'), ' & ', h('b', 'B'), '.'])),
129120
x('p', {xmlns: ns.html}, [x('a', 'A'), ' & ', x('b', 'B'), '.']),
130121
'should support elements'
131122
)
132123

133-
t.deepEqual(
124+
assert.deepEqual(
134125
toXast({
135126
type: 'element',
136127
tagName: 'template',
@@ -147,7 +138,7 @@ test('toXast', (t) => {
147138
'should support template elements'
148139
)
149140

150-
t.deepEqual(
141+
assert.deepEqual(
151142
toXast(h('p#a.b.c', {ariaLabel: 'd', dataE: 'f'}, 'Alpha')),
152143
x(
153144
'p',
@@ -162,98 +153,96 @@ test('toXast', (t) => {
162153
),
163154
'should support attributes'
164155
)
165-
166-
t.end()
167156
})
168157

169-
t.test('attributes', (t) => {
170-
t.deepEqual(
158+
await t.test('attributes', () => {
159+
assert.deepEqual(
171160
toXast(u('element', {tagName: 'br'}, [])),
172161
x('br', {xmlns: ns.html}),
173162
'should not fail for elements without properties'
174163
)
175164

176-
t.deepEqual(
165+
assert.deepEqual(
177166
toXast(u('element', {tagName: 'br', properties: {prop: null}}, [])),
178167
x('br', {xmlns: ns.html}),
179168
'should support attribute values: `null`'
180169
)
181170

182-
t.deepEqual(
171+
assert.deepEqual(
183172
toXast(u('element', {tagName: 'br', properties: {prop: undefined}}, [])),
184173
x('br', {xmlns: ns.html}),
185174
'should support attribute values: `undefined`'
186175
)
187176

188-
t.deepEqual(
177+
assert.deepEqual(
189178
toXast(u('element', {tagName: 'br', properties: {prop: Number.NaN}}, [])),
190179
x('br', {xmlns: ns.html}),
191180
'should support attribute values: `NaN`'
192181
)
193182

194-
t.deepEqual(
183+
assert.deepEqual(
195184
toXast(u('element', {tagName: 'br', properties: {prop: false}}, [])),
196185
x('br', {xmlns: ns.html}),
197186
'should support attribute values: `false`'
198187
)
199188

200-
t.deepEqual(
189+
assert.deepEqual(
201190
toXast(u('element', {tagName: 'br', properties: {prop: true}}, [])),
202191
x('br', {xmlns: ns.html, prop: ''}),
203192
'should support attribute values: `true`'
204193
)
205194

206-
t.deepEqual(
195+
assert.deepEqual(
207196
toXast(u('element', {tagName: 'script', properties: {async: 0}}, [])),
208197
x('script', {xmlns: ns.html}),
209198
'should support known falsey boolean attribute values'
210199
)
211200

212-
t.deepEqual(
201+
assert.deepEqual(
213202
toXast(u('element', {tagName: 'br', properties: {prop: 1.2}}, [])),
214203
x('br', {xmlns: ns.html, prop: '1.2'}),
215204
'should support numeric attribute values'
216205
)
217206

218-
t.deepEqual(
207+
assert.deepEqual(
219208
toXast(
220209
u('element', {tagName: 'br', properties: {className: ['a', 'b']}}, [])
221210
),
222211
x('br', {xmlns: ns.html, class: 'a b'}),
223212
'should support known space-separated attribute values'
224213
)
225214

226-
t.deepEqual(
215+
assert.deepEqual(
227216
toXast(
228217
u('element', {tagName: 'br', properties: {accept: ['a', 'b']}}, [])
229218
),
230219
x('br', {xmlns: ns.html, accept: 'a, b'}),
231220
'should support known comma-separated attribute values'
232221
)
233222

234-
t.deepEqual(
223+
assert.deepEqual(
235224
toXast(u('element', {tagName: 'br', properties: {xmlLang: 'en'}}, [])),
236225
x('br', {xmlns: ns.html, 'xml:lang': 'en'}),
237226
'should support attributes in the xml space (1)'
238227
)
239228

240-
t.deepEqual(
229+
assert.deepEqual(
241230
toXast(
242231
u('element', {tagName: 'svg', properties: {xmlSpace: 'preserve'}}, [])
243232
),
244233
x('svg', {xmlns: ns.svg, 'xml:space': 'preserve'}),
245234
'should support attributes in the xml space (2)'
246235
)
247236

248-
t.deepEqual(
237+
assert.deepEqual(
249238
toXast(
250239
u('element', {tagName: 'svg', properties: {xmlnsXLink: ns.xlink}}, [])
251240
),
252241
x('svg', {xmlns: ns.svg, 'xmlns:xlink': ns.xlink}),
253242
'should support attributes in the xmlns space'
254243
)
255244

256-
t.deepEqual(
245+
assert.deepEqual(
257246
toXast(
258247
u(
259248
'element',
@@ -275,15 +264,15 @@ test('toXast', (t) => {
275264
'should support attributes in the xlink space'
276265
)
277266

278-
t.deepEqual(
267+
assert.deepEqual(
279268
toXast(
280269
u('element', {tagName: 'x', properties: {'alpha:bravo': 'charlie'}}, [])
281270
),
282271
x('x', {xmlns: ns.html, 'alpha:bravo': 'charlie'}),
283272
'should include random prefixes'
284273
)
285274

286-
t.deepEqual(
275+
assert.deepEqual(
287276
toXast(
288277
u(
289278
'element',
@@ -298,12 +287,10 @@ test('toXast', (t) => {
298287
}),
299288
'should include undefined prefixed attributes'
300289
)
301-
302-
t.end()
303290
})
304291

305-
t.test('aria', (t) => {
306-
t.deepEqual(
292+
await t.test('aria', () => {
293+
assert.deepEqual(
307294
toXast(
308295
h('a', {ariaHidden: 'true', href: '#lorem-ipsum'}, [
309296
h('span.icon.icon-link')
@@ -314,12 +301,10 @@ test('toXast', (t) => {
314301
]),
315302
'should support aria'
316303
)
317-
318-
t.end()
319304
})
320305

321-
t.test('svg', (t) => {
322-
t.deepEqual(
306+
await t.test('svg', () => {
307+
assert.deepEqual(
323308
toXast(
324309
s(
325310
'svg',
@@ -353,7 +338,7 @@ test('toXast', (t) => {
353338
'should support svg'
354339
)
355340

356-
t.deepEqual(
341+
assert.deepEqual(
357342
toXast(
358343
u('root', [
359344
u('doctype', {name: 'html'}),
@@ -381,7 +366,7 @@ test('toXast', (t) => {
381366
'should support svg in html'
382367
)
383368

384-
t.deepEqual(
369+
assert.deepEqual(
385370
toXast(
386371
u('root', [
387372
u('doctype', {name: 'html'}),
@@ -414,12 +399,10 @@ test('toXast', (t) => {
414399
]),
415400
'should support html in svg in html'
416401
)
417-
418-
t.end()
419402
})
420403

421-
t.test('mathml', (t) => {
422-
t.deepEqual(
404+
await t.test('mathml', () => {
405+
assert.deepEqual(
423406
toXast(
424407
u('element', {tagName: 'p', properties: {}}, [
425408
u('element', {tagName: 'math', properties: {xmlns: ns.mathml}}, [
@@ -438,9 +421,5 @@ test('toXast', (t) => {
438421
]),
439422
'should *not really* support mathml'
440423
)
441-
442-
t.end()
443424
})
444-
445-
t.end()
446425
})

0 commit comments

Comments
 (0)