mirror of https://github.com/vuejs/vitepress
fix: compose markdown config when extending configs (#5236)
fix: compose extended markdown config hookspull/5237/head
parent
aef0371fb6
commit
04f4fbadbd
@ -0,0 +1,39 @@
|
||||
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'])
|
||||
})
|
||||
})
|
||||
Loading…
Reference in new issue