summaryrefslogtreecommitdiffstats
path: root/app/notification_test.go
diff options
context:
space:
mode:
authorSaturnino Abril <saturnino.abril@gmail.com>2018-05-12 00:57:20 +0800
committerDerrick Anderson <derrick@andersonwebstudio.com>2018-05-11 12:57:20 -0400
commit4ce37601a15a7af11d33465d1ae92de26f7fa498 (patch)
treeefc18357bf849d2c308d1cf0e5a5793f3a27bc9b /app/notification_test.go
parentb4db76cedbd99bfcfb1c12444c5bd84e92ac01dc (diff)
downloadchat-4ce37601a15a7af11d33465d1ae92de26f7fa498.tar.gz
chat-4ce37601a15a7af11d33465d1ae92de26f7fa498.tar.bz2
chat-4ce37601a15a7af11d33465d1ae92de26f7fa498.zip
add notification when @user, @here, @all and @channel has colon ":" at the end (#8760)
Diffstat (limited to 'app/notification_test.go')
-rw-r--r--app/notification_test.go52
1 files changed, 52 insertions, 0 deletions
diff --git a/app/notification_test.go b/app/notification_test.go
index 3b8b4adf5..818ad1d9d 100644
--- a/app/notification_test.go
+++ b/app/notification_test.go
@@ -148,6 +148,16 @@ func TestGetExplicitMentions(t *testing.T) {
OtherPotentialMentions: []string{"user"},
},
},
+ "OnePersonWithColonAtEnd": {
+ Message: "this is a message for @user:",
+ Keywords: map[string][]string{"this": {id1}},
+ Expected: &ExplicitMentions{
+ MentionedUserIds: map[string]bool{
+ id1: true,
+ },
+ OtherPotentialMentions: []string{"user"},
+ },
+ },
"MultiplePeopleWithOneWord": {
Message: "this is a message for @user",
Keywords: map[string][]string{"@user": {id1, id2}},
@@ -188,6 +198,18 @@ func TestGetExplicitMentions(t *testing.T) {
ChannelMentioned: true,
},
},
+
+ "ChannelWithColonAtEnd": {
+ Message: "this is a message for @channel:",
+ Keywords: map[string][]string{"@channel": {id1, id2}},
+ Expected: &ExplicitMentions{
+ MentionedUserIds: map[string]bool{
+ id1: true,
+ id2: true,
+ },
+ ChannelMentioned: true,
+ },
+ },
"CapitalizedChannel": {
Message: "this is an message for @cHaNNeL",
Keywords: map[string][]string{"@channel": {id1, id2}},
@@ -210,6 +232,17 @@ func TestGetExplicitMentions(t *testing.T) {
AllMentioned: true,
},
},
+ "AllWithColonAtEnd": {
+ Message: "this is a message for @all:",
+ Keywords: map[string][]string{"@all": {id1, id2}},
+ Expected: &ExplicitMentions{
+ MentionedUserIds: map[string]bool{
+ id1: true,
+ id2: true,
+ },
+ AllMentioned: true,
+ },
+ },
"CapitalizedAll": {
Message: "this is an message for @ALL",
Keywords: map[string][]string{"@all": {id1, id2}},
@@ -230,6 +263,15 @@ func TestGetExplicitMentions(t *testing.T) {
},
},
},
+ "AtUserWithColonAtEnd": {
+ Message: "this is a message for @user:",
+ Keywords: map[string][]string{"@user": {id1}},
+ Expected: &ExplicitMentions{
+ MentionedUserIds: map[string]bool{
+ id1: true,
+ },
+ },
+ },
"AtUserWithPeriodAtEndOfSentence": {
Message: "this is a message for @user.period.",
Keywords: map[string][]string{"@user.period": {id1}},
@@ -248,6 +290,15 @@ func TestGetExplicitMentions(t *testing.T) {
},
},
},
+ "UserWithColonAtEnd": {
+ Message: "this is a message for user:",
+ Keywords: map[string][]string{"user": {id1}},
+ Expected: &ExplicitMentions{
+ MentionedUserIds: map[string]bool{
+ id1: true,
+ },
+ },
+ },
"PotentialOutOfChannelUser": {
Message: "this is an message for @potential and @user",
Keywords: map[string][]string{"@user": {id1}},
@@ -452,6 +503,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,