mirror of https://github.com/vuejs/vitepress
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
879 B
40 lines
879 B
import { mergeConfig } from 'node/config'
|
|
import type { MarkdownItAsync } from 'markdown-it-async'
|
|
|
|
describe('node/config', () => {
|
|
test('merges markdown config hooks from extended configs', async () => {
|
|
const calls: string[] = []
|
|
const md = {} as MarkdownItAsync
|
|
|
|
const merged = mergeConfig(
|
|
{
|
|
markdown: {
|
|
lineNumbers: true,
|
|
config() {
|
|
calls.push('base')
|
|
}
|
|
}
|
|
},
|
|
{
|
|
markdown: {
|
|
attrs: {
|
|
allowedAttributes: ['id']
|
|
},
|
|
async config() {
|
|
calls.push('extended')
|
|
}
|
|
}
|
|
}
|
|
)
|
|
|
|
expect(merged.markdown?.lineNumbers).toBe(true)
|
|
expect(merged.markdown?.attrs).toEqual({
|
|
allowedAttributes: ['id']
|
|
})
|
|
|
|
await merged.markdown?.config?.(md)
|
|
|
|
expect(calls).toEqual(['base', 'extended'])
|
|
})
|
|
})
|