diff --git a/package.json b/package.json
index c7c98f3..ff1dbcb 100644
--- a/package.json
+++ b/package.json
@@ -41,13 +41,12 @@
"unist-util-visit": "^5.0.0"
},
"devDependencies": {
- "@types/tape": "^5.0.0",
+ "@types/node": "^20.0.0",
"c8": "^8.0.0",
"prettier": "^3.0.0",
"rehype": "^13.0.0",
"remark-cli": "^11.0.0",
"remark-preset-wooorm": "^9.0.0",
- "tape": "^5.0.0",
"type-coverage": "^2.0.0",
"typescript": "^5.0.0",
"xo": "^0.56.0"
diff --git a/test.js b/test.js
index 31a3ae8..c50a0ac 100644
--- a/test.js
+++ b/test.js
@@ -1,75 +1,70 @@
-import test from 'tape'
+import assert from 'node:assert/strict'
+import test from 'node:test'
import {rehype} from 'rehype'
import rehypeSlug from './index.js'
-test('rehypeSlug', (t) => {
- t.plan(4)
+test('rehypeSlug', async function (t) {
+ await t.test('should work', async function () {
+ const file = await rehype()
+ .data('settings', {fragment: true})
+ .use(rehypeSlug)
+ .process(
+ [
+ '',
+ ' Lorem ipsum 😪
',
+ ' dolor—sit—amet
',
+ ' consectetur & adipisicing
',
+ ' elit
',
+ ' elit
',
+ ' sed
',
+ ''
+ ].join('\n')
+ )
- rehype()
- .data('settings', {fragment: true})
- .use(rehypeSlug)
- .process(
+ assert.equal(
+ String(file),
[
'',
- ' Lorem ipsum 😪
',
- ' dolor—sit—amet
',
- ' consectetur & adipisicing
',
- ' elit
',
- ' elit
',
+ ' Lorem ipsum 😪
',
+ ' dolor—sit—amet
',
+ ' consectetur & adipisicing
',
+ ' elit
',
+ ' elit
',
' sed
',
''
- ].join('\n'),
- (error, file) => {
- t.ifErr(error, 'shouldn’t throw')
-
- t.equal(
- String(file),
- [
- '',
- ' Lorem ipsum 😪
',
- ' dolor—sit—amet
',
- ' consectetur & adipisicing
',
- ' elit
',
- ' elit
',
- ' sed
',
- ''
- ].join('\n'),
- 'should match'
- )
- }
+ ].join('\n')
)
+ })
+
+ await t.test('should support `options.prefix`', async function () {
+ const file = await rehype()
+ .data('settings', {fragment: true})
+ .use(rehypeSlug, {prefix: 'test-'})
+ .process(
+ [
+ '',
+ ' Lorem ipsum 😪
',
+ ' dolor—sit—amet
',
+ ' consectetur & adipisicing
',
+ ' elit
',
+ ' elit
',
+ ' sed
',
+ ''
+ ].join('\n')
+ )
- rehype()
- .data('settings', {fragment: true})
- .use(rehypeSlug, {prefix: 'test-'})
- .process(
+ assert.equal(
+ String(file),
[
'',
- ' Lorem ipsum 😪
',
- ' dolor—sit—amet
',
- ' consectetur & adipisicing
',
- ' elit
',
- ' elit
',
+ ' Lorem ipsum 😪
',
+ ' dolor—sit—amet
',
+ ' consectetur & adipisicing
',
+ ' elit
',
+ ' elit
',
' sed
',
''
- ].join('\n'),
- (error, file) => {
- t.ifErr(error, 'shouldn’t throw')
-
- t.equal(
- String(file),
- [
- '',
- ' Lorem ipsum 😪
',
- ' dolor—sit—amet
',
- ' consectetur & adipisicing
',
- ' elit
',
- ' elit
',
- ' sed
',
- ''
- ].join('\n'),
- 'should match'
- )
- }
+ ].join('\n')
)
+ })
})