Skip to content

Commit 2fae894

Browse files
committed
Use Node test runner
1 parent 8372200 commit 2fae894

File tree

3 files changed

+35
-38
lines changed

3 files changed

+35
-38
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
@@ -36,13 +36,12 @@
3636
"unist-util-is": "^5.0.0"
3737
},
3838
"devDependencies": {
39-
"@types/tape": "^4.0.0",
39+
"@types/node": "^18.0.0",
4040
"c8": "^7.0.0",
4141
"mdast-util-from-markdown": "^1.0.0",
4242
"prettier": "^2.0.0",
4343
"remark-cli": "^11.0.0",
4444
"remark-preset-wooorm": "^9.0.0",
45-
"tape": "^5.0.0",
4645
"type-coverage": "^2.0.0",
4746
"typescript": "^4.0.0",
4847
"xo": "^0.53.0"

test.js

Lines changed: 33 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
* @typedef {import('unist').Node} Node
33
*/
44

5-
import assert from 'node:assert'
6-
import test from 'tape'
5+
import assert from 'node:assert/strict'
6+
import test from 'node:test'
77
import {fromMarkdown} from 'mdast-util-from-markdown'
88
import {findBefore} from './index.js'
99

10-
test('`findBefore`', (t) => {
10+
test('`findBefore`', () => {
1111
const tree = fromMarkdown('Some *emphasis*, **importance**, and `code`.')
1212

1313
assert(tree.type === 'root')
@@ -18,7 +18,7 @@ test('`findBefore`', (t) => {
1818
const next = paragraph.children[1]
1919
assert(next.type === 'emphasis')
2020

21-
t.throws(
21+
assert.throws(
2222
() => {
2323
// @ts-expect-error runtime
2424
findBefore()
@@ -27,7 +27,7 @@ test('`findBefore`', (t) => {
2727
'should fail without parent'
2828
)
2929

30-
t.throws(
30+
assert.throws(
3131
() => {
3232
// @ts-expect-error runtime
3333
findBefore({type: 'foo'})
@@ -36,7 +36,7 @@ test('`findBefore`', (t) => {
3636
'should fail without parent node'
3737
)
3838

39-
t.throws(
39+
assert.throws(
4040
() => {
4141
// @ts-expect-error runtime
4242
findBefore({type: 'foo', children: []})
@@ -45,23 +45,23 @@ test('`findBefore`', (t) => {
4545
'should fail without index (#1)'
4646
)
4747

48-
t.throws(
48+
assert.throws(
4949
() => {
5050
findBefore({type: 'foo', children: []}, -1)
5151
},
5252
/Expected positive finite number as index/,
5353
'should fail without index (#2)'
5454
)
5555

56-
t.throws(
56+
assert.throws(
5757
() => {
5858
findBefore({type: 'foo', children: []}, {type: 'bar'})
5959
},
6060
/Expected child node or index/,
6161
'should fail without index (#3)'
6262
)
6363

64-
t.throws(
64+
assert.throws(
6565
() => {
6666
// @ts-expect-error runtime
6767
findBefore({type: 'foo', children: [{type: 'bar'}]}, 1, false)
@@ -70,7 +70,7 @@ test('`findBefore`', (t) => {
7070
'should fail for invalid `test` (#1)'
7171
)
7272

73-
t.throws(
73+
assert.throws(
7474
() => {
7575
// @ts-expect-error runtime
7676
findBefore({type: 'foo', children: [{type: 'bar'}]}, 1, true)
@@ -79,102 +79,100 @@ test('`findBefore`', (t) => {
7979
'should fail for invalid `test` (#2)'
8080
)
8181

82-
t.strictEqual(
82+
assert.strictEqual(
8383
findBefore(paragraph, paragraph.children[1]),
8484
head,
8585
'should return the preceding node when without `test` (#1)'
8686
)
87-
t.strictEqual(
87+
assert.strictEqual(
8888
findBefore(paragraph, 1),
8989
head,
9090
'should return the preceding node when without `test` (#2)'
9191
)
92-
t.strictEqual(
92+
assert.strictEqual(
9393
findBefore(paragraph, 0),
9494
null,
9595
'should return the preceding node when without `test` (#3)'
9696
)
9797

98-
t.strictEqual(
98+
assert.strictEqual(
9999
findBefore(paragraph, 100, head),
100100
head,
101101
'should return `node` when given a `node` and existing (#1)'
102102
)
103-
t.strictEqual(
103+
assert.strictEqual(
104104
findBefore(paragraph, paragraph.children[1], head),
105105
head,
106106
'should return `node` when given a `node` and existing (#2)'
107107
)
108-
t.strictEqual(
108+
assert.strictEqual(
109109
findBefore(paragraph, 1, head),
110110
head,
111111
'should return `node` when given a `node` and existing (#3)'
112112
)
113-
t.strictEqual(
113+
assert.strictEqual(
114114
findBefore(paragraph, head, head),
115115
null,
116116
'should return `node` when given a `node` and existing (#4)'
117117
)
118-
t.strictEqual(
118+
assert.strictEqual(
119119
findBefore(paragraph, 0, head),
120120
null,
121121
'should return `node` when given a `node` and existing (#5)'
122122
)
123-
t.strictEqual(
123+
assert.strictEqual(
124124
findBefore(paragraph, 1, next),
125125
null,
126126
'should return `node` when given a `node` and existing (#6)'
127127
)
128128

129-
t.strictEqual(
129+
assert.strictEqual(
130130
findBefore(paragraph, 100, 'strong'),
131131
paragraph.children[3],
132132
'should return a child when given a `type` and existing (#1)'
133133
)
134-
t.strictEqual(
134+
assert.strictEqual(
135135
findBefore(paragraph, 3, 'strong'),
136136
null,
137137
'should return a child when given a `type` and existing (#2)'
138138
)
139-
t.strictEqual(
139+
assert.strictEqual(
140140
findBefore(paragraph, paragraph.children[4], 'strong'),
141141
paragraph.children[3],
142142
'should return a child when given a `type` and existing (#3)'
143143
)
144-
t.strictEqual(
144+
assert.strictEqual(
145145
findBefore(paragraph, paragraph.children[3], 'strong'),
146146
null,
147147
'should return a child when given a `type` and existing (#4)'
148148
)
149149

150-
t.strictEqual(
151-
findBefore(paragraph, 100, test),
150+
assert.strictEqual(
151+
findBefore(paragraph, 100, check),
152152
paragraph.children[3],
153153
'should return a child when given a `test` and existing (#1)'
154154
)
155-
t.strictEqual(
156-
findBefore(paragraph, 3, test),
155+
assert.strictEqual(
156+
findBefore(paragraph, 3, check),
157157
null,
158158
'should return a child when given a `test` and existing (#2)'
159159
)
160-
t.strictEqual(
161-
findBefore(paragraph, paragraph.children[4], test),
160+
assert.strictEqual(
161+
findBefore(paragraph, paragraph.children[4], check),
162162
paragraph.children[3],
163163
'should return a child when given a `test` and existing (#3)'
164164
)
165-
t.strictEqual(
166-
findBefore(paragraph, paragraph.children[3], test),
165+
assert.strictEqual(
166+
findBefore(paragraph, paragraph.children[3], check),
167167
null,
168168
'should return a child when given a `test` and existing (#4)'
169169
)
170170

171171
/**
172172
* @param {Node} _
173-
* @param {number} n
173+
* @param {number | null | undefined} n
174174
*/
175-
function test(_, n) {
175+
function check(_, n) {
176176
return n === 3
177177
}
178-
179-
t.end()
180178
})

0 commit comments

Comments
 (0)