import test from 'node:test'
import assert from 'node:assert/strict'
import { renderMarkdown } from './markdown.js'

test('renderMarkdown renders common markdown and keeps raw html escaped', () => {
  const html = renderMarkdown(`# 项目介绍

- Spring Boot
- Vue3

\`\`\`bash
npm run dev
\`\`\`

<script>alert('xss')</script>`)

  assert.match(html, /<h1>项目介绍<\/h1>/)
  assert.match(html, /<li>Spring Boot<\/li>/)
  assert.match(html, /<pre><code class="language-bash">npm run dev\n<\/code><\/pre>/)
  assert.equal(html.includes('<script>'), false)
  assert.ok(html.includes('&lt;script&gt;alert'))
})
