杂务:更新 YumiNail 工作区

This commit is contained in:
xiaowang
2026-05-29 13:30:56 +08:00
parent 1d077d4089
commit 31cd06b5c9
16498 changed files with 10330586 additions and 2340 deletions
@@ -0,0 +1,24 @@
import { describe, expect, it } from 'vitest'
import { extractRichText, renderRichContent } from './rich-content'
describe('rich content helpers', () => {
it('renders markdown into html', () => {
const html = renderRichContent('# 标题\n\n- 甲\n- 乙\n\n**加粗** [链接](https://example.com)')
expect(html).toContain('<h1>标题</h1>')
expect(html).toContain('<ul>')
expect(html).toContain('<strong>加粗</strong>')
expect(html).toContain('<a href="https://example.com"')
})
it('keeps safe html and strips scripts', () => {
const html = renderRichContent('<p>hello <strong>world</strong></p><script>alert(1)</script>')
expect(html).toBe('<p>hello <strong>world</strong></p>')
})
it('extracts plain text from rich content', () => {
expect(extractRichText('<p>Hello <strong>world</strong></p>')).toBe('Hello world')
expect(extractRichText('## 标题\n\n内容')).toBe('标题 内容')
})
})