import { VFile } from 'vfile';
import remarkGfm from 'remark-gfm';
import unified from 'unified';
import parse from 'remark-parse';
import directive from 'remark-directive';
import remark2rehype from 'remark-rehype';
import html from 'rehype-stringify';
import rawHtml from 'rehype-raw';
import stripIndent from 'strip-indent';
import { tabsPlugin } from '../index';
const processMarkdown = (md): VFile => {
return unified()
.use(parse)
.use(directive)
.use(tabsPlugin)
.use(remark2rehype, { allowDangerousHtml: true })
.use(rawHtml)
.use(remarkGfm)
.use(html)
.processSync(md);
};
describe('Tabs Plugin', () => {
test('transform tabs directive to dx-tab-panel-list element', () => {
const markdown = stripIndent(`
::::::tabset{tabs='["Design", "Develop", "Specifications", "Accessibility"]'}
:::::tab
Test tab1
:::::
:::::tab
Test tab2
:::::
:::::tab
Test tab3
:::::
:::::tab
Test tab4
:::::
::::::
`);
const result = processMarkdown(markdown);
const contents = result.contents;
expect(contents).toEqual(
' Test tab1 Test tab2 Test tab3 Test tab4
Test tab1
Test tab2