mirror of
https://github.com/Smile-QWQ/SubTracker.git
synced 2026-06-03 07:29:51 +08:00
- add statistics page AI summary card with auto-generate and markdown rendering - introduce dashboard summary query/composable and markdown sanitization utility - add marked and dompurify dependencies for summary rendering - raise dashboard summary generate request timeout to 65000ms and cover it with tests
25 lines
782 B
TypeScript
25 lines
782 B
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { renderMarkdownToHtml } from '@/utils/simple-markdown'
|
|
|
|
describe('markdown renderer', () => {
|
|
it('renders headings, lists and paragraphs safely', () => {
|
|
const html = renderMarkdownToHtml(`## 总览
|
|
|
|
- 第一条
|
|
- 第二条
|
|
|
|
正文 **加粗** 与 *强调* 以及 \`code\`
|
|
<script>alert(1)</script>`)
|
|
|
|
expect(html).toContain('<h2>总览</h2>')
|
|
expect(html).toContain('<ul>')
|
|
expect(html).toContain('<li>第一条</li>')
|
|
expect(html).toContain('<li>第二条</li>')
|
|
expect(html).toContain('<strong>加粗</strong>')
|
|
expect(html).toContain('<em>强调</em>')
|
|
expect(html).toContain('<code>code</code>')
|
|
expect(html).not.toContain('<script>')
|
|
expect(html).not.toContain('alert(1)')
|
|
})
|
|
})
|