diff options
author | Harrison Healey <harrisonmhealey@gmail.com> | 2018-06-05 13:34:21 -0400 |
---|---|---|
committer | Carlos Tadeu Panato Junior <ctadeu@gmail.com> | 2018-06-05 19:34:21 +0200 |
commit | bca7339e4ccb410a1aa048842074af9518198b9e (patch) | |
tree | 86b7e4991816764a9af73452c7a2c8d027d26b7a /app/notification_test.go | |
parent | 5e36cbae09082d830ea4beb4f3049243d23121a1 (diff) | |
download | chat-bca7339e4ccb410a1aa048842074af9518198b9e.tar.gz chat-bca7339e4ccb410a1aa048842074af9518198b9e.tar.bz2 chat-bca7339e4ccb410a1aa048842074af9518198b9e.zip |
MM-10597 Improved handling of punctuation around notifications (#8901)
Diffstat (limited to 'app/notification_test.go')
-rw-r--r-- | app/notification_test.go | 52 |
1 files changed, 48 insertions, 4 deletions
diff --git a/app/notification_test.go b/app/notification_test.go index 1a4fb2859..fb8eef4d7 100644 --- a/app/notification_test.go +++ b/app/notification_test.go @@ -148,14 +148,58 @@ func TestGetExplicitMentions(t *testing.T) { OtherPotentialMentions: []string{"user"}, }, }, - "OnePersonWithColonAtEnd": { + "OnePersonWithPeriodAfter": { + Message: "this is a message for @user.", + Keywords: map[string][]string{"@user": {id1}}, + Expected: &ExplicitMentions{ + MentionedUserIds: map[string]bool{ + id1: true, + }, + }, + }, + "OnePersonWithPeriodBefore": { + Message: "this is a message for .@user", + Keywords: map[string][]string{"@user": {id1}}, + Expected: &ExplicitMentions{ + MentionedUserIds: map[string]bool{ + id1: true, + }, + }, + }, + "OnePersonWithColonAfter": { Message: "this is a message for @user:", - Keywords: map[string][]string{"this": {id1}}, + Keywords: map[string][]string{"@user": {id1}}, + Expected: &ExplicitMentions{ + MentionedUserIds: map[string]bool{ + id1: true, + }, + }, + }, + "OnePersonWithColonBefore": { + Message: "this is a message for :@user", + Keywords: map[string][]string{"@user": {id1}}, + Expected: &ExplicitMentions{ + MentionedUserIds: map[string]bool{ + id1: true, + }, + }, + }, + "OnePersonWithHyphenAfter": { + Message: "this is a message for @user.", + Keywords: map[string][]string{"@user": {id1}}, + Expected: &ExplicitMentions{ + MentionedUserIds: map[string]bool{ + id1: true, + }, + }, + }, + "OnePersonWithHyphenBefore": { + Message: "this is a message for -@user", + Keywords: map[string][]string{"@user": {id1}}, Expected: &ExplicitMentions{ MentionedUserIds: map[string]bool{ id1: true, }, - OtherPotentialMentions: []string{"user"}, }, }, "MultiplePeopleWithOneWord": { @@ -493,7 +537,7 @@ func TestGetExplicitMentionsAtHere(t *testing.T) { "(@here(": true, ")@here)": true, "-@here-": true, - "_@here_": false, // This case shouldn't mention since it would be mentioning "@here_" + "_@here_": true, "=@here=": true, "+@here+": true, "[@here[": true, |