@@ -112,7 +112,7 @@ describe('paragraph', () => {
112112 expect ( outputContent ) . toBe ( `${ inputContent } \n` )
113113 } )
114114
115- test ( 'link' , async ( ) => {
115+ test ( 'external link' , async ( ) => {
116116 const inputContent = '[Link](https://example.com)'
117117
118118 const expectedMDCJSON : MDCRoot = {
@@ -192,6 +192,84 @@ describe('paragraph', () => {
192192 expect ( outputContent ) . toBe ( `${ inputContent } \n` )
193193 } )
194194
195+ test ( 'relative link' , async ( ) => {
196+ const inputContent = '[Link](/test)'
197+
198+ const expectedMDCJSON : MDCRoot = {
199+ type : 'root' ,
200+ children : [
201+ {
202+ type : 'element' ,
203+ tag : 'p' ,
204+ props : { } ,
205+ children : [
206+ {
207+ type : 'element' ,
208+ tag : 'a' ,
209+ props : {
210+ href : '/test' ,
211+ } ,
212+ children : [
213+ {
214+ type : 'text' ,
215+ value : 'Link' ,
216+ } ,
217+ ] ,
218+ } ,
219+ ] ,
220+ } ,
221+ ] ,
222+ }
223+
224+ const expectedTiptapJSON : JSONContent = {
225+ type : 'doc' ,
226+ content : [
227+ {
228+ type : 'frontmatter' ,
229+ attrs : {
230+ frontmatter : { } ,
231+ } ,
232+ } ,
233+ {
234+ type : 'paragraph' ,
235+ attrs : { } ,
236+ content : [
237+ {
238+ type : 'text' ,
239+ marks : [
240+ {
241+ type : 'link' ,
242+ attrs : {
243+ href : '/test' ,
244+ } ,
245+ } ,
246+ ] ,
247+ text : 'Link' ,
248+ } ,
249+ ] ,
250+ } ,
251+ ] ,
252+ }
253+
254+ const document = await generateDocumentFromContent ( 'test.md' , inputContent , { compress : false } ) as DatabasePageItem
255+ expect ( document . body ) . toMatchObject ( expectedMDCJSON )
256+
257+ const tiptapJSON : JSONContent = await mdcToTiptap ( document . body as unknown as MDCRoot , { } )
258+ expect ( tiptapJSON ) . toMatchObject ( expectedTiptapJSON )
259+
260+ const generatedMdcJSON = await tiptapToMDC ( tiptapJSON )
261+ expect ( generatedMdcJSON . body ) . toMatchObject ( expectedMDCJSON )
262+
263+ const generatedDocument = createMockDocument ( 'docs/test.md' , {
264+ body : generatedMdcJSON . body as unknown as MarkdownRoot ,
265+ ...generatedMdcJSON . data ,
266+ } )
267+
268+ const outputContent = await generateContentFromDocument ( generatedDocument )
269+
270+ expect ( outputContent ) . toBe ( `${ inputContent } \n` )
271+ } )
272+
195273 test ( 'inline component' , async ( ) => {
196274 const inputContent = 'This is a :badge component'
197275
0 commit comments