summaryrefslogtreecommitdiffstats
path: root/app/notification_test.go
diff options
context:
space:
mode:
authorSaturnino Abril <saturnino.abril@gmail.com>2017-10-25 22:11:20 +0800
committerGitHub <noreply@github.com>2017-10-25 22:11:20 +0800
commitf63223286295a1261c950c482701b99963fb260c (patch)
treebfb56efaf64ef16047b6996733b719d27c71fe05 /app/notification_test.go
parent1d968eb55eae7f0f6db087c9e8466b11800b888a (diff)
downloadchat-f63223286295a1261c950c482701b99963fb260c.tar.gz
chat-f63223286295a1261c950c482701b99963fb260c.tar.bz2
chat-f63223286295a1261c950c482701b99963fb260c.zip
[PLT-7701] Fix emoji names that trigger mention (#7663)
* fix emoji names that trigger mention * remove regex and rearrange based on comment * make ":@here:" to not trigger a mention
Diffstat (limited to 'app/notification_test.go')
-rw-r--r--app/notification_test.go26
1 files changed, 25 insertions, 1 deletions
diff --git a/app/notification_test.go b/app/notification_test.go
index f5224e84e..51dba7c0e 100644
--- a/app/notification_test.go
+++ b/app/notification_test.go
@@ -200,6 +200,30 @@ func TestGetExplicitMentions(t *testing.T) {
if mentions, _, _, _, _ := GetExplicitMentions(message, keywords); len(mentions) != 1 || !mentions[id1] || mentions[id2] || mentions[id3] {
t.Fatal("should've only mentioned aaa")
}
+
+ message = ":smile:"
+ keywords = map[string][]string{"smile": {id1}, "smiley": {id2}, "smiley_cat": {id3}}
+ if mentions, _, _, _, _ := GetExplicitMentions(message, keywords); len(mentions) == 1 || mentions[id1] {
+ t.Fatal("should not mentioned smile")
+ }
+
+ message = "smile"
+ keywords = map[string][]string{"smile": {id1}, "smiley": {id2}, "smiley_cat": {id3}}
+ if mentions, _, _, _, _ := GetExplicitMentions(message, keywords); len(mentions) != 1 || !mentions[id1] || mentions[id2] || mentions[id3] {
+ t.Fatal("should've only mentioned smile")
+ }
+
+ message = ":smile"
+ keywords = map[string][]string{"smile": {id1}, "smiley": {id2}, "smiley_cat": {id3}}
+ if mentions, _, _, _, _ := GetExplicitMentions(message, keywords); len(mentions) != 1 || !mentions[id1] || mentions[id2] || mentions[id3] {
+ t.Fatal("should've only mentioned smile")
+ }
+
+ message = "smile:"
+ keywords = map[string][]string{"smile": {id1}, "smiley": {id2}, "smiley_cat": {id3}}
+ if mentions, _, _, _, _ := GetExplicitMentions(message, keywords); len(mentions) != 1 || !mentions[id1] || mentions[id2] || mentions[id3] {
+ t.Fatal("should've only mentioned smile")
+ }
}
func TestGetExplicitMentionsAtHere(t *testing.T) {
@@ -230,7 +254,7 @@ func TestGetExplicitMentionsAtHere(t *testing.T) {
"\\@here\\": true,
"|@here|": true,
";@here;": true,
- ":@here:": true,
+ ":@here:": false, // This case shouldn't trigger a mention since it follows the format of reactions e.g. :word:
"'@here'": true,
"\"@here\"": true,
",@here,": true,