types_test.go (view raw)
1package tgbotapi_test
2
3import (
4 "github.com/Syfaro/telegram-bot-api"
5 "testing"
6 "time"
7)
8
9func TestUserStringWith(t *testing.T) {
10 user := tgbotapi.User{0, "Test", "Test", ""}
11
12 if user.String() != "Test Test" {
13 t.Fail()
14 }
15}
16
17func TestUserStringWithUserName(t *testing.T) {
18 user := tgbotapi.User{0, "Test", "Test", "@test"}
19
20 if user.String() != "@test" {
21 t.Fail()
22 }
23}
24
25func TestMessageTime(t *testing.T) {
26 message := tgbotapi.Message{Date: 0}
27
28 date := time.Unix(0, 0)
29 if message.Time() != date {
30 t.Fail()
31 }
32}
33
34func TestChatIsPrivate(t *testing.T) {
35 chat := tgbotapi.Chat{ID: 10, Type: "private"}
36
37 if chat.IsPrivate() != true {
38 t.Fail()
39 }
40}
41
42func TestChatIsGroup(t *testing.T) {
43 chat := tgbotapi.Chat{ID: 10, Type: "group"}
44
45 if chat.IsGroup() != true {
46 t.Fail()
47 }
48}
49
50func TestChatIsChannel(t *testing.T) {
51 chat := tgbotapi.Chat{ID: 10, Type: "channel"}
52
53 if chat.IsChannel() != true {
54 t.Fail()
55 }
56}
57
58func TestChatIsSuperGroup(t *testing.T) {
59 chat := tgbotapi.Chat{ID: 10, Type: "supergroup"}
60
61 if !chat.IsSuperGroup() {
62 t.Fail()
63 }
64}
65
66func TestFileLink(t *testing.T) {
67 file := tgbotapi.File{FilePath: "test/test.txt"}
68
69 if file.Link("token") != "https://api.telegram.org/file/bottoken/test/test.txt" {
70 t.Fail()
71 }
72}