11import { expect , it } from 'vitest'
22import { parseMarkdown } from '../utils/parser'
33import { stringifyMarkdown } from '../../src/runtime/stringify'
4+ import type { MDCElement } from '@nuxtjs/mdc'
45
56it ( 'Element in heading' , async ( ) => {
67 const { body } = await parseMarkdown ( '### :hello' )
@@ -14,8 +15,40 @@ it('Element in heading', async () => {
1415 children : [ { type : 'element' , tag : 'hello' , props : { } , children : [ ] } ] ,
1516 } )
1617
17- const result = await stringifyMarkdown ( body )
18+ const result = await stringifyMarkdown ( body , { } )
1819 expect ( result ) . toMatchInlineSnapshot ( `
1920 "### :hello\n"
2021 ` )
2122} )
23+
24+ it ( '(autoUnwrap) component -> paragraph -> kbd' , async ( ) => {
25+ const { body } = await parseMarkdown ( '::tip\nYou can also use the shortcut :kbd{value="meta"} + :kbd{value="."} to redirect to the Studio route.\n::' , {
26+ remark : {
27+ plugins : {
28+ 'remark-mdc' : {
29+ options : {
30+ autoUnwrap : true ,
31+ } ,
32+ } ,
33+ } ,
34+ } ,
35+ } )
36+ expect ( body ) . toHaveProperty ( 'type' , 'root' )
37+
38+ expect ( body . children ) . toHaveLength ( 1 )
39+
40+ expect ( ( body . children [ 0 ] as MDCElement ) . children ?. [ 0 ] ?. type ) . toBe ( 'text' )
41+
42+ const result = await stringifyMarkdown ( body , { } , {
43+ plugins : {
44+ 'remark-mdc' : {
45+ options : {
46+ autoUnwrap : true ,
47+ } ,
48+ } ,
49+ } ,
50+ } )
51+ expect ( result ) . toMatchInlineSnapshot ( `
52+ "::tip\nYou can also use the shortcut :kbd{value="meta"} + :kbd{value="."} to redirect to the Studio route.\n::\n"
53+ ` )
54+ } )
0 commit comments