FILE / ScuroNeko/Laniakea

tgapi/parse_mode_test.go

Исходный файл и его история в репозитории.
FILE 269ccec0079b5e0a067633f88e45078ae1d1ebb3
Files
Laniakea/tgapi/parse_mode_test.go
T
ScuroNeko 83bcab6415 Rename tgapi request structs
Add MaybeInaccessibleMessage tests and godoc
Update wiki and Bot API docs for the new naming
2026-04-06 16:06:57 +03:00

38 lines
800 B
Go

package tgapi
import (
"encoding/json"
"strings"
"testing"
)
func TestParseNoneOmitsParseModeInJSON(t *testing.T) {
data, err := json.Marshal(SendMessage{
ChatID: 42,
Text: "hello",
ParseMode: ParseNone,
})
if err != nil {
t.Fatalf("Marshal returned error: %v", err)
}
if strings.Contains(string(data), `"parse_mode"`) {
t.Fatalf("expected parse_mode to be omitted, got %s", string(data))
}
}
func TestParseModeStillSerializesExplicitModes(t *testing.T) {
data, err := json.Marshal(SendMessage{
ChatID: 42,
Text: "hello",
ParseMode: ParseMDV2,
})
if err != nil {
t.Fatalf("Marshal returned error: %v", err)
}
if !strings.Contains(string(data), `"parse_mode":"MarkdownV2"`) {
t.Fatalf("expected MarkdownV2 parse_mode, got %s", string(data))
}
}