aboutsummaryrefslogtreecommitdiff
path: root/telegram/utils_test.go
diff options
context:
space:
mode:
authorBohdan Horbeshko <bodqhrohro@gmail.com>2024-01-10 22:30:00 +0300
committerBohdan Horbeshko <bodqhrohro@gmail.com>2024-01-10 22:30:00 +0300
commit4532748c8458971151dfb6b535b11b2a3e17a372 (patch)
treed74a5aabce0a9c614a8fa7f8eb27dfdf6b9d95d6 /telegram/utils_test.go
parentf2807779aad0dd0d463d396d7ae7e2de48a83c3b (diff)
Support chosen quotes in replies and replies from other chats
Diffstat (limited to 'telegram/utils_test.go')
-rw-r--r--telegram/utils_test.go93
1 files changed, 50 insertions, 43 deletions
diff --git a/telegram/utils_test.go b/telegram/utils_test.go
index 36b535c..534596f 100644
--- a/telegram/utils_test.go
+++ b/telegram/utils_test.go
@@ -436,15 +436,12 @@ func TestMessageToPrefix1(t *testing.T) {
},
},
}
- prefix, replyStart, replyEnd := (&Client{Session: &persistence.Session{}}).messageToPrefix(&message, "", "", nil)
+ prefix, gatewayReply := (&Client{Session: &persistence.Session{}}).messageToPrefix(&message, "", "")
if prefix != "➡ 42 | fwd: ziz" {
t.Errorf("Wrong prefix: %v", prefix)
}
- if replyStart != 0 {
- t.Errorf("Wrong replyStart: %v", replyStart)
- }
- if replyEnd != 0 {
- t.Errorf("Wrong replyEnd: %v", replyEnd)
+ if gatewayReply != nil {
+ t.Errorf("Reply is not nil: %v", gatewayReply)
}
}
@@ -457,15 +454,12 @@ func TestMessageToPrefix2(t *testing.T) {
},
},
}
- prefix, replyStart, replyEnd := (&Client{Session: &persistence.Session{}}).messageToPrefix(&message, "y.jpg", "", nil)
+ prefix, gatewayReply := (&Client{Session: &persistence.Session{}}).messageToPrefix(&message, "y.jpg", "")
if prefix != "⬅ 56 | fwd: (zaz) | preview: y.jpg" {
t.Errorf("Wrong prefix: %v", prefix)
}
- if replyStart != 0 {
- t.Errorf("Wrong replyStart: %v", replyStart)
- }
- if replyEnd != 0 {
- t.Errorf("Wrong replyEnd: %v", replyEnd)
+ if gatewayReply != nil {
+ t.Errorf("Reply is not nil: %v", gatewayReply)
}
}
@@ -478,15 +472,12 @@ func TestMessageToPrefix3(t *testing.T) {
},
},
}
- prefix, replyStart, replyEnd := (&Client{Session: &persistence.Session{AsciiArrows: true}}).messageToPrefix(&message, "", "a.jpg", nil)
+ prefix, gatewayReply := (&Client{Session: &persistence.Session{AsciiArrows: true}}).messageToPrefix(&message, "", "a.jpg")
if prefix != "< 56 | fwd: (zuz) | file: a.jpg" {
t.Errorf("Wrong prefix: %v", prefix)
}
- if replyStart != 0 {
- t.Errorf("Wrong replyStart: %v", replyStart)
- }
- if replyEnd != 0 {
- t.Errorf("Wrong replyEnd: %v", replyEnd)
+ if gatewayReply != nil {
+ t.Errorf("Reply is not nil: %v", gatewayReply)
}
}
@@ -495,15 +486,12 @@ func TestMessageToPrefix4(t *testing.T) {
Id: 23,
IsOutgoing: true,
}
- prefix, replyStart, replyEnd := (&Client{Session: &persistence.Session{AsciiArrows: true}}).messageToPrefix(&message, "", "", nil)
+ prefix, gatewayReply := (&Client{Session: &persistence.Session{AsciiArrows: true}}).messageToPrefix(&message, "", "")
if prefix != "> 23" {
t.Errorf("Wrong prefix: %v", prefix)
}
- if replyStart != 0 {
- t.Errorf("Wrong replyStart: %v", replyStart)
- }
- if replyEnd != 0 {
- t.Errorf("Wrong replyEnd: %v", replyEnd)
+ if gatewayReply != nil {
+ t.Errorf("Reply is not nil: %v", gatewayReply)
}
}
@@ -516,43 +504,62 @@ func TestMessageToPrefix5(t *testing.T) {
},
},
}
- prefix, replyStart, replyEnd := (&Client{Session: &persistence.Session{AsciiArrows: true}}).messageToPrefix(&message, "h.jpg", "a.jpg", nil)
+ prefix, gatewayReply := (&Client{Session: &persistence.Session{AsciiArrows: true}}).messageToPrefix(&message, "h.jpg", "a.jpg")
if prefix != "< 560 | fwd: (zyz) | preview: h.jpg | file: a.jpg" {
t.Errorf("Wrong prefix: %v", prefix)
}
- if replyStart != 0 {
- t.Errorf("Wrong replyStart: %v", replyStart)
- }
- if replyEnd != 0 {
- t.Errorf("Wrong replyEnd: %v", replyEnd)
+ if gatewayReply != nil {
+ t.Errorf("Reply is not nil: %v", gatewayReply)
}
}
func TestMessageToPrefix6(t *testing.T) {
message := client.Message{
Id: 23,
+ ChatId: 25,
IsOutgoing: true,
ReplyTo: &client.MessageReplyToMessage{
- MessageId: 42,
+ ChatId: 41,
+ Quote: &client.FormattedText{
+ Text: "tist\nuz\niz",
+ },
+ Origin: &client.MessageOriginHiddenUser{
+ SenderName: "ziz",
+ },
},
}
- reply := client.Message{
- Id: 42,
- Content: &client.MessageText{
- Text: &client.FormattedText{
- Text: "tist",
+ prefix, gatewayReply := (&Client{Session: &persistence.Session{AsciiArrows: true}}).messageToPrefix(&message, "", "")
+ if prefix != "> 23 | reply: ziz @ unknown contact: TDlib instance is offline | tist uz iz" {
+ t.Errorf("Wrong prefix: %v", prefix)
+ }
+ if gatewayReply != nil {
+ t.Errorf("Reply is not nil: %v", gatewayReply)
+ }
+}
+
+func TestMessageToPrefix7(t *testing.T) {
+ message := client.Message{
+ Id: 23,
+ ChatId: 42,
+ IsOutgoing: true,
+ ReplyTo: &client.MessageReplyToMessage{
+ ChatId: 41,
+ Content: &client.MessageText{
+ Text: &client.FormattedText{
+ Text: "tist",
+ },
+ },
+ Origin: &client.MessageOriginChannel{
+ AuthorSignature: "zaz",
},
},
}
- prefix, replyStart, replyEnd := (&Client{Session: &persistence.Session{AsciiArrows: true}}).messageToPrefix(&message, "", "", &reply)
- if prefix != "> 23 | reply: 42 | | tist" {
+ prefix, gatewayReply := (&Client{Session: &persistence.Session{AsciiArrows: true}}).messageToPrefix(&message, "", "")
+ if prefix != "> 23 | reply: (zaz) @ unknown contact: TDlib instance is offline | tist" {
t.Errorf("Wrong prefix: %v", prefix)
}
- if replyStart != 4 {
- t.Errorf("Wrong replyStart: %v", replyStart)
- }
- if replyEnd != 26 {
- t.Errorf("Wrong replyEnd: %v", replyEnd)
+ if gatewayReply != nil {
+ t.Errorf("Reply is not nil: %v", gatewayReply)
}
}