import { describe, it, expect } from 'vitest' import { replaceChapterTemplate, plainTextToEditorHtml } from '../../src/shared/chapter-template' const baseCtx = { chapterNumber: 1, chapterTitle: '测试', penName: '笔名', date: '2026-07-08', volumeName: '第一卷', previousChapterTitle: '上一章', outlineItem: '', characterList: '甲,乙' } describe('chapter-template', () => { it('UT-TEMPL-01: replaces chapterNumber and chapterTitle', () => { const result = replaceChapterTemplate('第{chapterNumber}章 {chapterTitle}', { ...baseCtx, chapterNumber: 5, chapterTitle: '觉醒' }) expect(result).toBe('第5章 觉醒') }) it('UT-TEMPL-02: replaces volumeName', () => { const result = replaceChapterTemplate('卷:{volumeName}', { ...baseCtx, volumeName: '第一卷 觉醒' }) expect(result).toBe('卷:第一卷 觉醒') }) it('UT-TEMPL-03: replaces characterList', () => { const result = replaceChapterTemplate('出场:{characterList}', baseCtx) expect(result).toBe('出场:甲,乙') }) it('plainTextToEditorHtml wraps paragraphs', () => { const html = plainTextToEditorHtml('第一段\n\n第二段') expect(html).toContain('

') expect(html).toContain('第一段') expect(html).toContain('第二段') }) })