Files
geo/apps/admin-web/src/lib/monitoring-answer-markdown.test.ts
T
root d2cb2faa61 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>
2026-07-12 14:57:16 +08:00

27 lines
1.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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('## 推荐清单')
})
})