Skip to content

Commit e28baca

Browse files
committed
Use Node test runner
1 parent 5ade7e4 commit e28baca

File tree

3 files changed

+15
-17
lines changed

3 files changed

+15
-17
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
@@ -41,13 +41,12 @@
4141
"unist-util-visit": "^4.0.0"
4242
},
4343
"devDependencies": {
44-
"@types/tape": "^4.0.0",
44+
"@types/node": "^18.0.0",
4545
"c8": "^7.0.0",
4646
"hastscript": "^7.0.0",
4747
"prettier": "^2.0.0",
4848
"remark-cli": "^11.0.0",
4949
"remark-preset-wooorm": "^9.0.0",
50-
"tape": "^5.0.0",
5150
"type-coverage": "^2.0.0",
5251
"typescript": "^4.0.0",
5352
"xo": "^0.53.0"

test.js

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import test from 'tape'
1+
import assert from 'node:assert/strict'
2+
import test from 'node:test'
23
import {h} from 'hastscript'
34
import {shiftHeading} from './index.js'
45

5-
test('shiftHeading', (t) => {
6-
t.throws(
6+
test('shiftHeading', () => {
7+
assert.throws(
78
() => {
89
// @ts-ignore runtime.
910
shiftHeading(h(''))
@@ -12,70 +13,68 @@ test('shiftHeading', (t) => {
1213
'should throw when not given a number'
1314
)
1415

15-
t.throws(
16+
assert.throws(
1617
() => {
1718
shiftHeading(h(''), Number.NaN)
1819
},
1920
/^Error: Expected a non-null finite integer, not `NaN`$/,
2021
'should throw when given not a number'
2122
)
2223

23-
t.throws(
24+
assert.throws(
2425
() => {
2526
shiftHeading(h(''), 0.1)
2627
},
2728
/^Error: Expected a non-null finite integer, not `0.1`$/,
2829
'should throw when not given an integer'
2930
)
3031

31-
t.throws(
32+
assert.throws(
3233
() => {
3334
shiftHeading(h(''), Number.POSITIVE_INFINITY)
3435
},
3536
/^Error: Expected a non-null finite integer, not `Infinity`$/,
3637
'should throw when not given a finite number'
3738
)
3839

39-
t.throws(
40+
assert.throws(
4041
() => {
4142
shiftHeading(h(''), 0)
4243
},
4344
/^Error: Expected a non-null finite integer, not `0`$/,
4445
'should throw when not given a non-null number'
4546
)
4647

47-
t.deepEqual(
48+
assert.deepEqual(
4849
shiftHeading(h('h1', 'Alpha'), 1),
4950
h('h2', 'Alpha'),
5051
'should shift nodes upwards'
5152
)
5253

53-
t.deepEqual(
54+
assert.deepEqual(
5455
shiftHeading(h('h2', 'Bravo'), -1),
5556
h('h1', 'Bravo'),
5657
'should shift nodes downwards'
5758
)
5859

59-
t.deepEqual(
60+
assert.deepEqual(
6061
shiftHeading(h('h2', 'Charlie'), -2),
6162
h('h1', 'Charlie'),
6263
'should not shift upwards past h1'
6364
)
6465

65-
t.deepEqual(
66+
assert.deepEqual(
6667
shiftHeading(h('h5', 'Delta'), 2),
6768
h('h6', 'Delta'),
6869
'should not shift downwards past h6'
6970
)
7071

71-
t.deepEqual(
72+
assert.deepEqual(
7273
shiftHeading(
7374
h('main', [h('h1', 'Echo'), h('p', 'Foxtrot'), h('h5', 'Golf')]),
7475
2
7576
),
7677
h('main', [h('h3', 'Echo'), h('p', 'Foxtrot'), h('h6', 'Golf')]),
7778
'should change a tree'
7879
)
79-
80-
t.end()
8180
})

0 commit comments

Comments
 (0)