Skip to content

Commit 46dc069

Browse files
committed
Use Node test runner
1 parent 2e4b854 commit 46dc069

File tree

3 files changed

+35
-37
lines changed

3 files changed

+35
-37
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 & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@
33
* @typedef {import('unist').Parent} Parent
44
*/
55

6-
import test from 'tape'
6+
import assert from 'node:assert/strict'
7+
import test from 'node:test'
78
import {fromMarkdown} from 'mdast-util-from-markdown'
89
import {findAfter} from './index.js'
910

1011
const tree = fromMarkdown('Some _emphasis_, **importance**, and `code`.')
1112
const paragraph = /** @type {Parent} */ (tree.children[0])
1213
const children = paragraph.children
1314

14-
test('unist-util-find-after', (t) => {
15-
t.throws(
15+
test('unist-util-find-after', () => {
16+
assert.throws(
1617
() => {
1718
// @ts-expect-error runtime.
1819
findAfter()
@@ -21,7 +22,7 @@ test('unist-util-find-after', (t) => {
2122
'should fail without parent'
2223
)
2324

24-
t.throws(
25+
assert.throws(
2526
() => {
2627
// @ts-expect-error runtime.
2728
findAfter({type: 'foo'})
@@ -30,7 +31,7 @@ test('unist-util-find-after', (t) => {
3031
'should fail without parent node'
3132
)
3233

33-
t.throws(
34+
assert.throws(
3435
() => {
3536
// @ts-expect-error runtime.
3637
findAfter({type: 'foo', children: []})
@@ -39,23 +40,23 @@ test('unist-util-find-after', (t) => {
3940
'should fail without index (#1)'
4041
)
4142

42-
t.throws(
43+
assert.throws(
4344
() => {
4445
findAfter({type: 'foo', children: []}, -1)
4546
},
4647
/Expected positive finite number as index/,
4748
'should fail without index (#2)'
4849
)
4950

50-
t.throws(
51+
assert.throws(
5152
() => {
5253
findAfter({type: 'foo', children: []}, {type: 'bar'})
5354
},
5455
/Expected child node or index/,
5556
'should fail without index (#3)'
5657
)
5758

58-
t.throws(
59+
assert.throws(
5960
() => {
6061
findAfter(
6162
{type: 'foo', children: [{type: 'bar'}, {type: 'baz'}]},
@@ -68,7 +69,7 @@ test('unist-util-find-after', (t) => {
6869
'should fail for invalid `test` (#1)'
6970
)
7071

71-
t.throws(
72+
assert.throws(
7273
() => {
7374
findAfter(
7475
{type: 'foo', children: [{type: 'bar'}, {type: 'baz'}]},
@@ -81,102 +82,100 @@ test('unist-util-find-after', (t) => {
8182
'should fail for invalid `test` (#2)'
8283
)
8384

84-
t.strictEqual(
85+
assert.strictEqual(
8586
findAfter(paragraph, children[1]),
8687
children[2],
8788
'should return the following node when without `test` (#1)'
8889
)
89-
t.strictEqual(
90+
assert.strictEqual(
9091
findAfter(paragraph, 1),
9192
children[2],
9293
'should return the following node when without `test` (#1)'
9394
)
94-
t.strictEqual(
95+
assert.strictEqual(
9596
findAfter(paragraph, 7),
9697
null,
9798
'should return the following node when without `test` (#1)'
9899
)
99100

100-
t.strictEqual(
101+
assert.strictEqual(
101102
findAfter(paragraph, 0, children[6]),
102103
children[6],
103104
'should return `node` when given a `node` and existing (#1)'
104105
)
105-
t.strictEqual(
106+
assert.strictEqual(
106107
findAfter(paragraph, children[0], children[1]),
107108
children[1],
108109
'should return `node` when given a `node` and existing (#2)'
109110
)
110-
t.strictEqual(
111+
assert.strictEqual(
111112
findAfter(paragraph, 0, children[1]),
112113
children[1],
113114
'should return `node` when given a `node` and existing (#3)'
114115
)
115-
t.strictEqual(
116+
assert.strictEqual(
116117
findAfter(paragraph, children[0], children[0]),
117118
null,
118119
'should return `node` when given a `node` and existing (#4)'
119120
)
120-
t.strictEqual(
121+
assert.strictEqual(
121122
findAfter(paragraph, 0, children[0]),
122123
null,
123124
'should return `node` when given a `node` and existing (#5)'
124125
)
125-
t.strictEqual(
126+
assert.strictEqual(
126127
findAfter(paragraph, 1, children[1]),
127128
null,
128129
'should return `node` when given a `node` and existing (#6)'
129130
)
130131

131-
t.strictEqual(
132+
assert.strictEqual(
132133
findAfter(paragraph, 0, 'strong'),
133134
children[3],
134135
'should return a child when given a `type` and existing (#1)'
135136
)
136-
t.strictEqual(
137+
assert.strictEqual(
137138
findAfter(paragraph, 3, 'strong'),
138139
null,
139140
'should return a child when given a `type` and existing (#2)'
140141
)
141-
t.strictEqual(
142+
assert.strictEqual(
142143
findAfter(paragraph, children[0], 'strong'),
143144
children[3],
144145
'should return a child when given a `type` and existing (#3)'
145146
)
146-
t.strictEqual(
147+
assert.strictEqual(
147148
findAfter(paragraph, children[3], 'strong'),
148149
null,
149150
'should return a child when given a `type` and existing (#4)'
150151
)
151152

152-
t.strictEqual(
153-
findAfter(paragraph, 0, test),
153+
assert.strictEqual(
154+
findAfter(paragraph, 0, check),
154155
children[5],
155156
'should return a child when given a `test` and existing (#1)'
156157
)
157-
t.strictEqual(
158-
findAfter(paragraph, 5, test),
158+
assert.strictEqual(
159+
findAfter(paragraph, 5, check),
159160
null,
160161
'should return a child when given a `test` and existing (#2)'
161162
)
162-
t.strictEqual(
163-
findAfter(paragraph, children[4], test),
163+
assert.strictEqual(
164+
findAfter(paragraph, children[4], check),
164165
children[5],
165166
'should return a child when given a `test` and existing (#3)'
166167
)
167-
t.strictEqual(
168-
findAfter(paragraph, children[6], test),
168+
assert.strictEqual(
169+
findAfter(paragraph, children[6], check),
169170
null,
170171
'should return a child when given a `test` and existing (#4)'
171172
)
172173

173174
/**
174175
* @param {Node} _
175-
* @param {number} n
176+
* @param {number | null | undefined} n
176177
*/
177-
function test(_, n) {
178+
function check(_, n) {
178179
return n === 5
179180
}
180-
181-
t.end()
182181
})

0 commit comments

Comments
 (0)