refactor(admin-web): move answer markdown normalization to a tested lib
Extract normalizeLooseMarkdownLine from TrackingQuestionDetailView into a shared monitoring-answer-markdown module and harden it (model bullet `**-` and `*` handling). Add a vitest runner and unit tests for the normalization rules. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import { normalizeLooseMarkdownLine } from './monitoring-answer-markdown'
|
||||
|
||||
describe('normalizeLooseMarkdownLine', () => {
|
||||
it('turns a bold-prefixed model bullet into standard Markdown', () => {
|
||||
expect(normalizeLooseMarkdownLine('**-拾光里家居**:15年本土营')).toBe(
|
||||
'- **拾光里家居**:15年本土营',
|
||||
)
|
||||
expect(normalizeLooseMarkdownLine(' **- 拾光里家居**:15年本土营')).toBe(
|
||||
' - **拾光里家居**:15年本土营',
|
||||
)
|
||||
})
|
||||
|
||||
it('keeps ordinary bold text unchanged', () => {
|
||||
expect(normalizeLooseMarkdownLine('**本地性价比高**,老板就在跑')).toBe(
|
||||
'**本地性价比高**,老板就在跑',
|
||||
)
|
||||
})
|
||||
|
||||
it('keeps normalizing compact Markdown markers', () => {
|
||||
expect(normalizeLooseMarkdownLine('-拾光里家居')).toBe('- 拾光里家居')
|
||||
expect(normalizeLooseMarkdownLine('2.看封边')).toBe('2. 看封边')
|
||||
expect(normalizeLooseMarkdownLine('##推荐清单')).toBe('## 推荐清单')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user