-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
compile.test.ts
45 lines (42 loc) · 1.31 KB
/
compile.test.ts
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
33
34
35
36
37
38
39
40
41
42
43
44
45
import fs from 'node:fs/promises'
import path from 'node:path'
import { compileMdx } from '../src/compile'
import { it, describe, expect } from 'vitest'
import { CWD } from '../src/constants'
type Name =
| 'code-h1.mdx'
| 'code-with-text-h1.mdx'
| 'dynamic-h1.mdx'
| 'no-h1.mdx'
| 'static-h1.mdx'
function loadFixture(name: Name) {
const filePath = path.join(CWD, '__test__', 'fixture', 'headings', name)
return fs.readFile(filePath, 'utf8')
}
describe('process heading', () => {
it('code-h1', async () => {
const data = await loadFixture('code-h1.mdx')
const result = await compileMdx(data)
expect(result).toMatchSnapshot()
})
it('code-with-text-h1', async () => {
const data = await loadFixture('code-with-text-h1.mdx')
const result = await compileMdx(data)
expect(result).toMatchSnapshot()
})
it('static-h1', async () => {
const data = await loadFixture('static-h1.mdx')
const result = await compileMdx(data)
expect(result).toMatchSnapshot()
})
it('dynamic-h1', async () => {
const data = await loadFixture('dynamic-h1.mdx')
const result = await compileMdx(data)
expect(result).toMatchSnapshot()
})
it('no-h1', async () => {
const data = await loadFixture('no-h1.mdx')
const result = await compileMdx(data)
expect(result).toMatchSnapshot()
})
})