Skip to content

Commit 9950dad

Browse files
committed
Use Node test runner
1 parent 7c30b33 commit 9950dad

File tree

3 files changed

+29
-25
lines changed

3 files changed

+29
-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/gallium
2121
- node

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@
4242
"unist-util-visit": "^4.0.0"
4343
},
4444
"devDependencies": {
45-
"@types/tape": "^4.0.0",
45+
"@types/node": "^18.0.0",
4646
"c8": "^7.0.0",
47+
"mdast-util-from-markdown": "^1.2.0",
4748
"prettier": "^2.0.0",
4849
"remark": "^14.0.0",
4950
"remark-cli": "^11.0.0",
5051
"remark-preset-wooorm": "^9.0.0",
51-
"tape": "^5.0.0",
5252
"type-coverage": "^2.0.0",
5353
"typescript": "^4.0.0",
5454
"unist-util-remove-position": "^4.0.0",

test/index.js

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,44 @@
22
* @typedef {import('mdast').Root} Root
33
*/
44

5-
import fs from 'node:fs'
6-
import path from 'node:path'
7-
import test from 'tape'
8-
import {remark} from 'remark'
5+
import assert from 'node:assert/strict'
6+
import fs from 'node:fs/promises'
7+
import test from 'node:test'
8+
import {fromMarkdown} from 'mdast-util-from-markdown'
99
import {removePosition} from 'unist-util-remove-position'
1010
import {normalizeHeadings} from '../index.js'
1111

12-
test('Multiple top-level headings', (t) => {
13-
check(t, 'no-headings', 'No-op if there is no headings')
14-
check(t, 'no-titles', 'No-op if there is no top-level headings')
15-
check(t, 'one-title', 'No-op if there is a single top-level heading')
16-
check(t, 'two-titles', 'Makes the second header one level deeper')
17-
check(t, 'more-titles', 'Shifts all other headings one level deeper')
18-
t.end()
12+
test('Multiple top-level headings', async () => {
13+
await check('no-headings', 'No-op if there is no headings')
14+
await check('no-titles', 'No-op if there is no top-level headings')
15+
await check('one-title', 'No-op if there is a single top-level heading')
16+
await check('two-titles', 'Makes the second header one level deeper')
17+
await check('more-titles', 'Shifts all other headings one level deeper')
1918
})
2019

21-
test('Level 7', (t) => {
22-
check(t, 'hierarchy', 'There is no depth level 7')
23-
t.end()
20+
test('Level 7', async () => {
21+
await check('hierarchy', 'There is no depth level 7')
2422
})
2523

2624
/**
27-
* @param {import('tape').Test} t
2825
* @param {string} test
2926
* @param {string} message
27+
* @returns {Promise<void>}
3028
*/
31-
function check(t, test, message) {
32-
const input = fs.readFileSync(path.join('test', 'fixture', test + '.in'))
33-
const output = fs.readFileSync(path.join('test', 'fixture', test + '.out'))
34-
const root = /** @type {Root} */ (remark().parse(input))
29+
async function check(test, message) {
30+
const input = await fs.readFile(
31+
new URL('fixture/' + test + '.in', import.meta.url)
32+
)
33+
const output = await fs.readFile(
34+
new URL('fixture/' + test + '.out', import.meta.url)
35+
)
36+
const actual = fromMarkdown(input)
37+
const expected = fromMarkdown(output)
38+
normalizeHeadings(actual)
3539

36-
t.deepEqual(
37-
removePosition(normalizeHeadings(root), true),
38-
removePosition(remark().parse(output), true),
40+
assert.deepEqual(
41+
removePosition(actual, true),
42+
removePosition(expected, true),
3943
message
4044
)
4145
}

0 commit comments

Comments
 (0)