Skip to content

Commit 94e3060

Browse files
committed
Use Node test runner
1 parent 355596a commit 94e3060

File tree

3 files changed

+23
-25
lines changed

3 files changed

+23
-25
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
@@ -38,13 +38,12 @@
3838
"unist-util-visit-parents": "^5.0.0"
3939
},
4040
"devDependencies": {
41-
"@types/tape": "^4.0.0",
41+
"@types/node": "^18.0.0",
4242
"c8": "^7.0.0",
4343
"hastscript": "^7.0.0",
4444
"prettier": "^2.0.0",
4545
"remark-cli": "^11.0.0",
4646
"remark-preset-wooorm": "^9.0.0",
47-
"tape": "^5.0.0",
4847
"type-coverage": "^2.0.0",
4948
"typescript": "^4.0.0",
5049
"xo": "^0.53.0"

test.js

Lines changed: 21 additions & 22 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 {findAndReplace} from './index.js'
45

5-
test('findAndReplace', (t) => {
6-
t.throws(
6+
test('findAndReplace', () => {
7+
assert.throws(
78
() => {
89
// @ts-expect-error runtime.
910
findAndReplace(create(), true)
@@ -12,7 +13,7 @@ test('findAndReplace', (t) => {
1213
'should throw on invalid search and replaces'
1314
)
1415

15-
t.deepEqual(
16+
assert.deepEqual(
1617
findAndReplace(create(), 'emphasis'),
1718
h('p', [
1819
'Some ',
@@ -26,7 +27,7 @@ test('findAndReplace', (t) => {
2627
'should remove without `replace`'
2728
)
2829

29-
t.deepEqual(
30+
assert.deepEqual(
3031
findAndReplace(create(), 'emphasis', '!!!'),
3132
h('p', [
3233
'Some ',
@@ -40,7 +41,7 @@ test('findAndReplace', (t) => {
4041
'should work when given `find` and `replace`'
4142
)
4243

43-
t.deepEqual(
44+
assert.deepEqual(
4445
findAndReplace(
4546
create(),
4647
/em(\w+)is/,
@@ -58,7 +59,7 @@ test('findAndReplace', (t) => {
5859
'should work when given `find` as a `RegExp` and `replace` as a `Function`'
5960
)
6061

61-
t.deepEqual(
62+
assert.deepEqual(
6263
findAndReplace(create(), 'emphasis', () => ''),
6364
h('p', [
6465
'Some ',
@@ -72,7 +73,7 @@ test('findAndReplace', (t) => {
7273
'should work when given `replace` returns an empty string'
7374
)
7475

75-
t.deepEqual(
76+
assert.deepEqual(
7677
findAndReplace(create(), 'emphasis', () => h('a', h('b', 'c'))),
7778
h('p', [
7879
'Some ',
@@ -86,7 +87,7 @@ test('findAndReplace', (t) => {
8687
'should work when given `replace` returns a node'
8788
)
8889

89-
t.deepEqual(
90+
assert.deepEqual(
9091
findAndReplace(create(), 'emphasis', () => [h('a'), h('b', 'c')]),
9192
h('p', [
9293
'Some ',
@@ -100,7 +101,7 @@ test('findAndReplace', (t) => {
100101
'should work when given `replace` returns a list of nodes'
101102
)
102103

103-
t.deepEqual(
104+
assert.deepEqual(
104105
findAndReplace(create(), [
105106
['emphasis', '!!!'],
106107
['importance', '???']
@@ -117,7 +118,7 @@ test('findAndReplace', (t) => {
117118
'should work when given `search` as an matrix of strings'
118119
)
119120

120-
t.deepEqual(
121+
assert.deepEqual(
121122
findAndReplace(create(), {code: 'hacks', ',': '!'}),
122123
h('p', [
123124
'Some ',
@@ -133,7 +134,7 @@ test('findAndReplace', (t) => {
133134
'should work when given `search` as an object of strings'
134135
)
135136

136-
t.deepEqual(
137+
assert.deepEqual(
137138
findAndReplace(create(), /\Bmp\B/, '[MP]'),
138139
h('p', [
139140
'Some ',
@@ -147,7 +148,7 @@ test('findAndReplace', (t) => {
147148
'should work on partial matches'
148149
)
149150

150-
t.deepEqual(
151+
assert.deepEqual(
151152
findAndReplace(create(), {
152153
emphasis() {
153154
return h('a', 'importance')
@@ -166,7 +167,7 @@ test('findAndReplace', (t) => {
166167
'should find-and-replace recursively'
167168
)
168169

169-
t.deepEqual(
170+
assert.deepEqual(
170171
findAndReplace(
171172
h('p', [
172173
'Some ',
@@ -193,13 +194,13 @@ test('findAndReplace', (t) => {
193194
'should ignore from options'
194195
)
195196

196-
t.deepEqual(
197+
assert.deepEqual(
197198
findAndReplace(create(), 'emphasis', () => false),
198199
create(),
199200
'should not replace when returning `false`'
200201
)
201202

202-
t.deepEqual(
203+
assert.deepEqual(
203204
findAndReplace(h('p', 'Some emphasis, importance, and code.'), {
204205
importance(/** @type {string} */ match) {
205206
return h('strong', match)
@@ -215,7 +216,7 @@ test('findAndReplace', (t) => {
215216
'should not be order-sensitive with strings'
216217
)
217218

218-
t.deepEqual(
219+
assert.deepEqual(
219220
findAndReplace(h('p', 'aaa bbb'), [
220221
[
221222
/\b\w+\b/g,
@@ -227,7 +228,7 @@ test('findAndReplace', (t) => {
227228
h('p', [h('strong', 'aaa'), ' bbb']),
228229
'should support a match, and then a `false`'
229230
)
230-
t.deepEqual(
231+
assert.deepEqual(
231232
findAndReplace(h('p', 'Some emphasis, importance, and code.'), [
232233
[
233234
/importance/g,
@@ -252,7 +253,7 @@ test('findAndReplace', (t) => {
252253
'should not be order-sensitive with regexes'
253254
)
254255

255-
t.deepEqual(
256+
assert.deepEqual(
256257
findAndReplace(create(), 'and', 'alert(1)'),
257258
h('p', [
258259
'Some ',
@@ -268,7 +269,7 @@ test('findAndReplace', (t) => {
268269
'security: replacer as string (safe)'
269270
)
270271

271-
t.deepEqual(
272+
assert.deepEqual(
272273
findAndReplace(create(), 'and', () => h('script', 'alert(1)')),
273274
h('p', [
274275
'Some ',
@@ -283,8 +284,6 @@ test('findAndReplace', (t) => {
283284
]),
284285
'security: replacer as function (unsafe)'
285286
)
286-
287-
t.end()
288287
})
289288

290289
function create() {

0 commit comments

Comments
 (0)