Skip to content

Commit bc86318

Browse files
committed
test: add tests for readme Markdown content extraction
1 parent 93bcbfa commit bc86318

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/unit/server/utils/readme.spec.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,3 +307,24 @@ describe('Markdown File URL Resolution', () => {
307307
})
308308
})
309309
})
310+
311+
describe('Markdown Content Extraction', () => {
312+
describe('Markdown', () => {
313+
it('returns original markdown content unchanged', async () => {
314+
const markdown = `# Title\n\nSome **bold** text and a [link](https://example.com).`
315+
const result = await renderReadmeHtml(markdown, 'test-pkg')
316+
317+
expect(result.md).toBe(markdown)
318+
})
319+
})
320+
describe('HTML', () => {
321+
it('returns sanitized html', async () => {
322+
const markdown = `# Title\n\nSome **bold** text and a [link](https://example.com).`
323+
const result = await renderReadmeHtml(markdown, 'test-pkg')
324+
325+
expect(result.html).toBe(`<h3 id="user-content-title" data-level="1">Title</h3>
326+
<p>Some <strong>bold</strong> text and a <a href="https://example.com" rel="nofollow noreferrer noopener" target="_blank">link</a>.</p>
327+
`)
328+
})
329+
})
330+
})

0 commit comments

Comments
 (0)