FILE / ScuroNeko/Laniakea
tgrich/input_fmt_test.go
Исходный файл и его история в репозитории.
(fix): runtime reliability (tests): regression coverage (doc): v1.1 release notes
45 lines
1.6 KiB
Go
45 lines
1.6 KiB
Go
package tgrich
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"git.scuroneko.dev/scuroneko/laniakea/tgapi"
|
|
)
|
|
|
|
func TestMediaConstructorsSetTypes(t *testing.T) {
|
|
cases := []struct {
|
|
name string
|
|
blockType tgapi.InputRichType
|
|
mediaType tgapi.InputMediaType
|
|
}{
|
|
{"animation", Animation(tgapi.InputMedia{Media: "animation"}).Type, Animation(tgapi.InputMedia{Media: "animation"}).Animation.Type},
|
|
{"audio", Audio(tgapi.InputMedia{Media: "audio"}).Type, Audio(tgapi.InputMedia{Media: "audio"}).Audio.Type},
|
|
{"photo", Photo(tgapi.InputMedia{Media: "photo"}).Type, Photo(tgapi.InputMedia{Media: "photo"}).Photo.Type},
|
|
{"video", Video(tgapi.InputMedia{Media: "video"}).Type, Video(tgapi.InputMedia{Media: "video"}).Video.Type},
|
|
{"voice note", VoiceNote(tgapi.InputMedia{Media: "voice"}).Type, VoiceNote(tgapi.InputMedia{Media: "voice"}).VoiceNote.Type},
|
|
}
|
|
|
|
for _, tt := range cases {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if string(tt.blockType) != string(tt.mediaType) {
|
|
t.Errorf("block type = %q, media type = %q", tt.blockType, tt.mediaType)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestMediaConstructorWithCaption(t *testing.T) {
|
|
caption := tgapi.RichBlockCaption{Text: tgapi.RichTextPlain("caption")}
|
|
if block := AnimationWithCaption(tgapi.InputMedia{Media: "animation"}, caption); block.Caption == nil || *block.Caption != caption {
|
|
t.Fatal("AnimationWithCaption did not preserve the caption")
|
|
}
|
|
}
|
|
|
|
func TestOlPreservesCheckboxState(t *testing.T) {
|
|
item := NewListItem(P(Text("item"))).SetCheckbox().SetChecked().Build()
|
|
list := Ol(OlOpts{}, item)
|
|
if len(list.Items) != 1 || !list.Items[0].HasCheckbox || !list.Items[0].IsChecked {
|
|
t.Fatalf("Ol() item = %#v", list.Items)
|
|
}
|
|
}
|