Files
Memoh/internal/channel/format_test.go
T
Menci 36d50738b5 fix(channel): consistent markdown rendering across all Telegram paths (#210)
- Extract ContainsMarkdown to shared channel package
- Auto-detect markdown in normalizeOutboundMessage and MCP send tool
- Apply markdown-to-HTML conversion during streaming deltas, not just
  on the final message
- Remove resolveTelegramParseMode which incorrectly returned Telegram's
  native "Markdown" mode instead of converting to HTML
- Fix all 14 Telegram send/edit paths for consistent parse mode handling
- Reset parseMode for plain-text error messages to avoid HTML corruption
2026-03-09 13:06:44 +08:00

36 lines
853 B
Go

package channel
import "testing"
func TestContainsMarkdown(t *testing.T) {
t.Parallel()
tests := []struct {
name string
text string
want bool
}{
{"empty", "", false},
{"plain", "hello world", false},
{"bold", "this is **bold** text", true},
{"italic", "this is *italic* text", true},
{"code", "use `fmt.Println`", true},
{"fenced_code", "```go\nfmt.Println()\n```", true},
{"heading", "# Title", true},
{"link", "[click](https://example.com)", true},
{"unordered_list", "- item one", true},
{"ordered_list", "1. first item", true},
{"strikethrough", "this is ~~deleted~~ text", true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
got := ContainsMarkdown(tt.text)
if got != tt.want {
t.Errorf("ContainsMarkdown(%q) = %v, want %v", tt.text, got, tt.want)
}
})
}
}