summaryrefslogtreecommitdiffstats
path: root/api/slackimport_test.go
diff options
context:
space:
mode:
authorGeorge Goldberg <george@gberg.me>2016-11-29 19:07:07 +0000
committerJoram Wilander <jwawilander@gmail.com>2016-11-29 14:07:07 -0500
commite7710cf1d270eefd4d4f42bfe2017baec496b34a (patch)
treeac1cc4f92a5570b781893f74228625eb5d1b4aa3 /api/slackimport_test.go
parent7f911d1632b37e0a84cb9fdfe604d0efd1b14538 (diff)
downloadchat-e7710cf1d270eefd4d4f42bfe2017baec496b34a.tar.gz
chat-e7710cf1d270eefd4d4f42bfe2017baec496b34a.tar.bz2
chat-e7710cf1d270eefd4d4f42bfe2017baec496b34a.zip
PLT-4847 Fix formatting of links imported from Slack. (#4674)
This fixes mailto: links built from email addresses posted to Slack as described in the ticket, but also fixes any other type of URL that has been auto-linked in the Slack messages.
Diffstat (limited to 'api/slackimport_test.go')
-rw-r--r--api/slackimport_test.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/api/slackimport_test.go b/api/slackimport_test.go
index d78424ac0..efe6e635f 100644
--- a/api/slackimport_test.go
+++ b/api/slackimport_test.go
@@ -217,3 +217,24 @@ func TestSlackSanitiseChannelProperties(t *testing.T) {
t.Fatalf("Unexpected alterations to the channel properties: %v", c2s.Header)
}
}
+
+func TestSlackConvertPostsMarkup(t *testing.T) {
+ input := make(map[string][]SlackPost)
+ input["test"] = []SlackPost{
+ {
+ Text: "This message contains a link to <https://google.com|Google>.",
+ },
+ {
+ Text: "This message contains a mailto link to <mailto:me@example.com|me@example.com> in it.",
+ },
+ }
+
+ output := SlackConvertPostsMarkup(input)
+
+ if output["test"][0].Text != "This message contains a link to [Google](https://google.com)." {
+ t.Fatalf("Unexpected message after markup translation: %v", output["test"][0].Text)
+ }
+ if output["test"][1].Text != "This message contains a mailto link to [me@example.com](mailto:me@example.com) in it." {
+ t.Fatalf("Unexpected message after markup translation: %v", output["test"][0].Text)
+ }
+}