forked from tucnak/telebot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions_test.go
48 lines (39 loc) · 1.48 KB
/
options_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package telebot
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestBtn(t *testing.T) {
r := &ReplyMarkup{}
assert.Equal(t, &ReplyButton{Text: "T"}, r.Text("T").Reply())
assert.Equal(t, &ReplyButton{Text: "T", Contact: true}, r.Contact("T").Reply())
assert.Equal(t, &ReplyButton{Text: "T", Location: true}, r.Location("T").Reply())
assert.Equal(t, &ReplyButton{Text: "T", Poll: PollAny}, r.Poll("T", PollAny).Reply())
assert.Nil(t, r.Data("T", "u").Reply())
assert.Equal(t, &InlineButton{Unique: "u", Text: "T"}, r.Data("T", "u").Inline())
assert.Equal(t, &InlineButton{Unique: "u", Text: "T", Data: "1|2"}, r.Data("T", "u", "1", "2").Inline())
assert.Equal(t, &InlineButton{Text: "T", URL: "url"}, r.URL("T", "url").Inline())
assert.Equal(t, &InlineButton{Text: "T", InlineQuery: "q"}, r.Query("T", "q").Inline())
assert.Equal(t, &InlineButton{Text: "T", InlineQueryChat: "q"}, r.QueryChat("T", "q").Inline())
assert.Equal(t, &InlineButton{Text: "T", Login: &Login{Text: "T"}}, r.Login("T", &Login{Text: "T"}).Inline())
}
func TestReplyInline(t *testing.T) {
r := &ReplyMarkup{}
r.Reply(
r.Row(r.Text("Menu")),
r.Row(r.Text("Settings")),
)
assert.Equal(t, [][]ReplyButton{
{{Text: "Menu"}},
{{Text: "Settings"}},
}, r.ReplyKeyboard)
i := &ReplyMarkup{}
i.Inline(r.Row(
r.Data("Previous", "prev"),
r.Data("Next", "next"),
))
assert.Equal(t, [][]InlineButton{{
{Unique: "prev", Text: "Previous"},
{Unique: "next", Text: "Next"},
}}, i.InlineKeyboard)
}