Skip to content

Commit

Permalink
Update tsconfig.json, use node:test
Browse files Browse the repository at this point in the history
Closes GH-21.

Reviewed-by: Remco Haszing <[email protected]>
Reviewed-by: Titus Wormer <[email protected]>
  • Loading branch information
ChristianMurphy authored Feb 6, 2023
1 parent b527e60 commit 7bfa975
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ jobs:
strategy:
matrix:
node:
- lts/erbium
- lts/gallium
- node
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"unified": "^10.0.0"
},
"devDependencies": {
"@types/tape": "^4.0.0",
"@types/node": "^18.0.0",
"c8": "^7.0.0",
"prettier": "^2.0.0",
"rehype-stringify": "^9.0.0",
Expand All @@ -44,7 +44,6 @@
"remark-preset-wooorm": "^9.0.0",
"remark-rehype": "^10.0.0",
"rimraf": "^3.0.0",
"tape": "^5.0.0",
"type-coverage": "^2.0.0",
"typescript": "^4.0.0",
"unist-util-visit": "^4.0.0",
Expand Down
42 changes: 16 additions & 26 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,40 @@
* @typedef {import('hast').Root} Root
*/

import test from 'tape'
import test from 'node:test'
import assert from 'node:assert/strict'
import {unified} from 'unified'
import {visit} from 'unist-util-visit'
import remarkParse from 'remark-parse'
import remarkRehype from 'remark-rehype'
import rehypeStringify from 'rehype-stringify'
import rehypeRaw from './index.js'

test('rehypeRaw', (t) => {
t.plan(2)
const markdown = `<div class="note">
unified()
A mix of *markdown* and <em>HTML</em>.
</div>`

const html = `<div class="note">
<p>A mix of <em>markdown</em> and <em>HTML</em>.</p>
</div>`

test('rehypeRaw', async () => {
const file = await unified()
.use(remarkParse)
.use(remarkRehype, {allowDangerousHtml: true})
.use(rehypeRaw)
.use(
/** @type {import('unified').Plugin<Array<void>, Root>} */
() => (root) => {
visit(root, 'raw', () => {
t.fail('should not include `raw` in tree after `rehype-raw`')
assert.fail('should not include `raw` in tree after `rehype-raw`')
})
}
)
.use(rehypeStringify)
.process(
[
'<div class="note">',
'',
'A mix of *markdown* and <em>HTML</em>.',
'',
'</div>'
].join('\n'),
(error, file) => {
t.ifErr(error, 'should not fail')
.process(markdown)

t.equal(
String(file),
[
'<div class="note">',
'<p>A mix of <em>markdown</em> and <em>HTML</em>.</p>',
'</div>'
].join('\n'),
'should equal the fixture'
)
}
)
assert.equal(String(file), html, 'should equal the fixture')
})
9 changes: 3 additions & 6 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
{
"include": ["*.js"],
"compilerOptions": {
"target": "ES2020",
"lib": ["ES2020"],
"module": "ES2020",
"moduleResolution": "node",
"allowJs": true,
"target": "es2021",
"lib": ["es2021"],
"module": "node16",
"checkJs": true,
"declaration": true,
"emitDeclarationOnly": true,
"allowSyntheticDefaultImports": true,
"skipLibCheck": true,
"strict": true
}
Expand Down

0 comments on commit 7bfa975

Please sign in to comment.