-
Notifications
You must be signed in to change notification settings - Fork 7
/
index.test.js
32 lines (29 loc) · 1.35 KB
/
index.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import markdownDefaults from './index'
test('mdx options default', () => {
const opts = markdownDefaults()
expect(opts.remarkPlugins).toHaveLength(4)
expect(opts.remarkPlugins[0][0].name).toBe('includeMarkdownPlugin')
expect(opts.remarkPlugins[1][0].name).toBe('anchorLinksPlugin')
expect(opts.remarkPlugins[2].name).toBe('paragraphCustomAlertsPlugin')
expect(opts.remarkPlugins[3][0].name).toBe('typographyPlugin')
expect(opts.rehypePlugins[0][0].name).toBe('')
})
test('mdx options with custom plugins & options', () => {
const opts = markdownDefaults({
addRemarkPlugins: [function foo() {}],
addRehypePlugins: [function bar() {}],
resolveIncludes: 'foo',
enableMath: true,
})
expect(opts.remarkPlugins[0][0].name).toBe('includeMarkdownPlugin')
expect(opts.remarkPlugins[0][1].resolveFrom).toBe('foo')
expect(opts.remarkPlugins[1][0].name).toBe('anchorLinksPlugin')
expect(opts.remarkPlugins[2].name).toBe('paragraphCustomAlertsPlugin')
expect(opts.remarkPlugins[3][0].name).toBe('typographyPlugin')
expect(opts.remarkPlugins[4].name).toBe('foo')
expect(opts.remarkPlugins[5].name).toBe('remarkMath')
expect(opts.rehypePlugins[0][0].name).toBe('')
expect(opts.rehypePlugins[1].name).toBe('rehypeSurfaceCodeNewlines')
expect(opts.rehypePlugins[2].name).toBe('bar')
expect(opts.rehypePlugins[3].name).toBe('rehypeKatex')
})