summaryrefslogtreecommitdiffstats
path: root/app/notification_test.go
diff options
context:
space:
mode:
authorHarrison Healey <harrisonmhealey@gmail.com>2017-09-15 08:37:29 -0400
committerJoram Wilander <jwawilander@gmail.com>2017-09-15 08:37:29 -0400
commit2a6cd44f23e1b3207debaa73801f0c63a2c81126 (patch)
tree5dbb9ce895449036546df12d7b083751750c4085 /app/notification_test.go
parent2be5577b88e5ff85a98b0a2b3e3a43b90cc99c6d (diff)
downloadchat-2a6cd44f23e1b3207debaa73801f0c63a2c81126.tar.gz
chat-2a6cd44f23e1b3207debaa73801f0c63a2c81126.tar.bz2
chat-2a6cd44f23e1b3207debaa73801f0c63a2c81126.zip
PLT-7509 Stopped processing special mentions for change of header/purpose messages (#7410)
Diffstat (limited to 'app/notification_test.go')
-rw-r--r--app/notification_test.go35
1 files changed, 29 insertions, 6 deletions
diff --git a/app/notification_test.go b/app/notification_test.go
index c262d068d..28c931d1f 100644
--- a/app/notification_test.go
+++ b/app/notification_test.go
@@ -420,7 +420,7 @@ func TestGetMentionKeywords(t *testing.T) {
}
profiles := map[string]*model.User{user1.Id: user1}
- mentions := GetMentionKeywordsInChannel(profiles)
+ mentions := GetMentionKeywordsInChannel(profiles, true)
if len(mentions) != 3 {
t.Fatal("should've returned three mention keywords")
} else if ids, ok := mentions["user"]; !ok || ids[0] != user1.Id {
@@ -442,7 +442,7 @@ func TestGetMentionKeywords(t *testing.T) {
}
profiles = map[string]*model.User{user2.Id: user2}
- mentions = GetMentionKeywordsInChannel(profiles)
+ mentions = GetMentionKeywordsInChannel(profiles, true)
if len(mentions) != 2 {
t.Fatal("should've returned two mention keyword")
} else if ids, ok := mentions["First"]; !ok || ids[0] != user2.Id {
@@ -460,7 +460,7 @@ func TestGetMentionKeywords(t *testing.T) {
}
profiles = map[string]*model.User{user3.Id: user3}
- mentions = GetMentionKeywordsInChannel(profiles)
+ mentions = GetMentionKeywordsInChannel(profiles, true)
if len(mentions) != 3 {
t.Fatal("should've returned three mention keywords")
} else if ids, ok := mentions["@channel"]; !ok || ids[0] != user3.Id {
@@ -482,7 +482,7 @@ func TestGetMentionKeywords(t *testing.T) {
}
profiles = map[string]*model.User{user4.Id: user4}
- mentions = GetMentionKeywordsInChannel(profiles)
+ mentions = GetMentionKeywordsInChannel(profiles, true)
if len(mentions) != 6 {
t.Fatal("should've returned six mention keywords")
} else if ids, ok := mentions["user"]; !ok || ids[0] != user4.Id {
@@ -524,7 +524,7 @@ func TestGetMentionKeywords(t *testing.T) {
user3.Id: user3,
user4.Id: user4,
}
- mentions = GetMentionKeywordsInChannel(profiles)
+ mentions = GetMentionKeywordsInChannel(profiles, true)
if len(mentions) != 6 {
t.Fatal("should've returned six mention keywords")
} else if ids, ok := mentions["user"]; !ok || len(ids) != 2 || (ids[0] != user1.Id && ids[1] != user1.Id) || (ids[0] != user4.Id && ids[1] != user4.Id) {
@@ -534,12 +534,35 @@ func TestGetMentionKeywords(t *testing.T) {
} else if ids, ok := mentions["mention"]; !ok || len(ids) != 2 || (ids[0] != user1.Id && ids[1] != user1.Id) || (ids[0] != user4.Id && ids[1] != user4.Id) {
t.Fatal("should've mentioned user1 and user4 with mention")
} else if ids, ok := mentions["First"]; !ok || len(ids) != 2 || (ids[0] != user2.Id && ids[1] != user2.Id) || (ids[0] != user4.Id && ids[1] != user4.Id) {
- t.Fatal("should've mentioned user2 and user4 with mention")
+ t.Fatal("should've mentioned user2 and user4 with First")
} else if ids, ok := mentions["@channel"]; !ok || len(ids) != 2 || (ids[0] != user3.Id && ids[1] != user3.Id) || (ids[0] != user4.Id && ids[1] != user4.Id) {
t.Fatal("should've mentioned user3 and user4 with @channel")
} else if ids, ok := mentions["@all"]; !ok || len(ids) != 2 || (ids[0] != user3.Id && ids[1] != user3.Id) || (ids[0] != user4.Id && ids[1] != user4.Id) {
t.Fatal("should've mentioned user3 and user4 with @all")
}
+
+ // no special mentions
+ profiles = map[string]*model.User{
+ user1.Id: user1,
+ }
+ mentions = GetMentionKeywordsInChannel(profiles, false)
+ if len(mentions) != 3 {
+ t.Fatal("should've returned three mention keywords")
+ } else if ids, ok := mentions["user"]; !ok || len(ids) != 1 || ids[0] != user1.Id {
+ t.Fatal("should've mentioned user1 with user")
+ } else if ids, ok := mentions["@user"]; !ok || len(ids) != 2 || ids[0] != user1.Id || ids[1] != user1.Id {
+ t.Fatal("should've mentioned user1 twice with @user")
+ } else if ids, ok := mentions["mention"]; !ok || len(ids) != 1 || ids[0] != user1.Id {
+ t.Fatal("should've mentioned user1 with mention")
+ } else if _, ok := mentions["First"]; ok {
+ t.Fatal("should not have mentioned user1 with First")
+ } else if _, ok := mentions["@channel"]; ok {
+ t.Fatal("should not have mentioned any user with @channel")
+ } else if _, ok := mentions["@all"]; ok {
+ t.Fatal("should not have mentioned any user with @all")
+ } else if _, ok := mentions["@here"]; ok {
+ t.Fatal("should not have mentioned any user with @here")
+ }
}
func TestDoesNotifyPropsAllowPushNotification(t *testing.T) {