|
| 1 | +package tgbotapi_test |
| 2 | + |
| 3 | +import ( |
| 4 | + "github.com/go-telegram-bot-api/telegram-bot-api" |
| 5 | + "testing" |
| 6 | +) |
| 7 | + |
| 8 | +func TestNewInlineQueryResultArticle(t *testing.T) { |
| 9 | + result := tgbotapi.NewInlineQueryResultArticle("id", "title", "message") |
| 10 | + |
| 11 | + if result.Type != "article" || |
| 12 | + result.ID != "id" || |
| 13 | + result.Title != "title" || |
| 14 | + result.InputMessageContent.(tgbotapi.InputTextMessageContent).Text != "message" { |
| 15 | + t.Fail() |
| 16 | + } |
| 17 | +} |
| 18 | + |
| 19 | +func TestNewInlineQueryResultGIF(t *testing.T) { |
| 20 | + result := tgbotapi.NewInlineQueryResultGIF("id", "google.com") |
| 21 | + |
| 22 | + if result.Type != "gif" || |
| 23 | + result.ID != "id" || |
| 24 | + result.URL != "google.com" { |
| 25 | + t.Fail() |
| 26 | + } |
| 27 | +} |
| 28 | + |
| 29 | +func TestNewInlineQueryResultMPEG4GIF(t *testing.T) { |
| 30 | + result := tgbotapi.NewInlineQueryResultMPEG4GIF("id", "google.com") |
| 31 | + |
| 32 | + if result.Type != "mpeg4_gif" || |
| 33 | + result.ID != "id" || |
| 34 | + result.URL != "google.com" { |
| 35 | + t.Fail() |
| 36 | + } |
| 37 | +} |
| 38 | + |
| 39 | +func TestNewInlineQueryResultPhoto(t *testing.T) { |
| 40 | + result := tgbotapi.NewInlineQueryResultPhoto("id", "google.com") |
| 41 | + |
| 42 | + if result.Type != "photo" || |
| 43 | + result.ID != "id" || |
| 44 | + result.URL != "google.com" { |
| 45 | + t.Fail() |
| 46 | + } |
| 47 | +} |
| 48 | + |
| 49 | +func TestNewInlineQueryResultVideo(t *testing.T) { |
| 50 | + result := tgbotapi.NewInlineQueryResultVideo("id", "google.com") |
| 51 | + |
| 52 | + if result.Type != "video" || |
| 53 | + result.ID != "id" || |
| 54 | + result.URL != "google.com" { |
| 55 | + } |
| 56 | +} |
| 57 | + |
| 58 | +func TestNewInlineQueryResultAudio(t *testing.T) { |
| 59 | + result := tgbotapi.NewInlineQueryResultAudio("id", "google.com", "title") |
| 60 | + |
| 61 | + if result.Type != "audio" || |
| 62 | + result.ID != "id" || |
| 63 | + result.URL != "google.com" || |
| 64 | + result.Title != "title" { |
| 65 | + } |
| 66 | +} |
| 67 | + |
| 68 | +func TestNewInlineQueryResultVoice(t *testing.T) { |
| 69 | + result := tgbotapi.NewInlineQueryResultVoice("id", "google.com", "title") |
| 70 | + |
| 71 | + if result.Type != "voice" || |
| 72 | + result.ID != "id" || |
| 73 | + result.URL != "google.com" || |
| 74 | + result.Title != "title" { |
| 75 | + } |
| 76 | +} |
| 77 | + |
| 78 | +func TestNewInlineQueryResultDocument(t *testing.T) { |
| 79 | + result := tgbotapi.NewInlineQueryResultDocument("id", "google.com", "title", "mime/type") |
| 80 | + |
| 81 | + if result.Type != "document" || |
| 82 | + result.ID != "id" || |
| 83 | + result.URL != "google.com" || |
| 84 | + result.Title != "title" || |
| 85 | + result.MimeType != "mime/type" { |
| 86 | + } |
| 87 | +} |
| 88 | + |
| 89 | +func TestNewInlineQueryResultLocation(t *testing.T) { |
| 90 | + result := tgbotapi.NewInlineQueryResultLocation("id", "name", 40, 50) |
| 91 | + |
| 92 | + if result.Type != "location" || |
| 93 | + result.ID != "id" || |
| 94 | + result.Title != "name" || |
| 95 | + result.Latitude != 40 || |
| 96 | + result.Longitude != 50 { |
| 97 | + } |
| 98 | +} |
| 99 | + |
| 100 | +func TestNewEditMessageText(t *testing.T) { |
| 101 | + edit := tgbotapi.NewEditMessageText(ChatID, ReplyToMessageID, "new text") |
| 102 | + |
| 103 | + if edit.Text != "new text" || |
| 104 | + edit.BaseEdit.ChatID != ChatID || |
| 105 | + edit.BaseEdit.MessageID != ReplyToMessageID { |
| 106 | + t.Fail() |
| 107 | + } |
| 108 | +} |
| 109 | + |
| 110 | +func TestNewEditMessageCaption(t *testing.T) { |
| 111 | + edit := tgbotapi.NewEditMessageCaption(ChatID, ReplyToMessageID, "new caption") |
| 112 | + |
| 113 | + if edit.Caption != "new caption" || |
| 114 | + edit.BaseEdit.ChatID != ChatID || |
| 115 | + edit.BaseEdit.MessageID != ReplyToMessageID { |
| 116 | + t.Fail() |
| 117 | + } |
| 118 | +} |
| 119 | + |
| 120 | +func TestNewEditMessageReplyMarkup(t *testing.T) { |
| 121 | + markup := tgbotapi.InlineKeyboardMarkup{ |
| 122 | + InlineKeyboard: [][]tgbotapi.InlineKeyboardButton{ |
| 123 | + []tgbotapi.InlineKeyboardButton{ |
| 124 | + tgbotapi.InlineKeyboardButton{Text: "test"}, |
| 125 | + }, |
| 126 | + }, |
| 127 | + } |
| 128 | + |
| 129 | + edit := tgbotapi.NewEditMessageReplyMarkup(ChatID, ReplyToMessageID, markup) |
| 130 | + |
| 131 | + if edit.ReplyMarkup.InlineKeyboard[0][0].Text != "test" || |
| 132 | + edit.BaseEdit.ChatID != ChatID || |
| 133 | + edit.BaseEdit.MessageID != ReplyToMessageID { |
| 134 | + t.Fail() |
| 135 | + } |
| 136 | + |
| 137 | +} |
0 commit comments