Skip to content

Commit

Permalink
test: Add test case.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed May 17, 2021
1 parent 8bf8432 commit 4fc5f6d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
22 changes: 22 additions & 0 deletions __tests__/index.test.ts
Expand Up @@ -4,6 +4,7 @@ const unified = require("unified");
const stringify = require('rehype-stringify')
const rehypeRaw = require('rehype-raw')
const remarkParse = require('remark-parse')
const gfm = require('remark-gfm')
const remark2rehype = require('remark-rehype')
const rehypeAttrs = require('../lib')

Expand Down Expand Up @@ -148,6 +149,27 @@ describe('rehype-attr test case', () => {
.toString()
expect(htmlStr).toEqual(data.expected);
});
});

[
{
title: 'options="attr" - Delete <del> `~~Text~~`',
markdown: 'This is a ~~title~~<!--rehype:style=color:pink;-->',
expected: '<p>This is a <del style="color:pink;">title</del><!--rehype:style=color:pink;--></p>',
}
].forEach((data, idx) => {
it(data.title, async () => {
const htmlStr = unified()
.use(remarkParse)
.use(gfm)
.use(remark2rehype, { allowDangerousHtml: true })
.use(rehypeRaw)
.use(rehypeAttrs, { properties: 'attr' })
.use(stringify)
.processSync(data.markdown)
.toString()
expect(htmlStr).toEqual(data.expected);
});
})

});
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -48,6 +48,7 @@
"rehype": "11.0.0",
"rehype-raw": "5.1.0",
"rehype-stringify": "8.0.0",
"remark-gfm": "^1.0.0",
"remark-parse": "9.0.0",
"remark-rehype": "8.1.0",
"tsbb": "2.1.2"
Expand Down

0 comments on commit 4fc5f6d

Please sign in to comment.