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
|
package telegram
import (
"testing"
"time"
"github.com/zelenin/go-tdlib/client"
)
const testTimeFormat string = "15:03 02/01/2006"
func TestOnlineStatus(t *testing.T) {
show, status := userStatusToText(client.UserStatus(&client.UserStatusOnline{}))
if show != "" || status != "Online" {
t.Errorf("Wrong online status: %v, %v", show, status)
}
}
func TestOnlineRecently(t *testing.T) {
show, status := userStatusToText(client.UserStatus(&client.UserStatusRecently{}))
if show != "dnd" || status != "Last seen recently" {
t.Errorf("Wrong recently status: %v, %v", show, status)
}
}
func TestOnlineOfflineAway(t *testing.T) {
timestamp := time.Now().Unix() - 3599
time := time.Unix(timestamp, 0)
show, status := userStatusToText(client.UserStatus(&client.UserStatusOffline{WasOnline: int32(timestamp)}))
if show != "away" || status != "Last seen at "+time.Format(testTimeFormat) {
t.Errorf("Wrong away status: %v, %v", show, status)
}
}
func TestOnlineOfflineXa(t *testing.T) {
timestamp := time.Now().Unix() - 3601
time := time.Unix(timestamp, 0)
show, status := userStatusToText(client.UserStatus(&client.UserStatusOffline{WasOnline: int32(timestamp)}))
if show != "xa" || status != "Last seen at "+time.Format(testTimeFormat) {
t.Errorf("Wrong xa status: %v, %v", show, status)
}
}
|