summaryrefslogtreecommitdiff
path: root/test/formatter_test.exs
diff options
context:
space:
mode:
authorlain <lain@soykaf.club>2020-07-27 16:35:47 +0000
committerlain <lain@soykaf.club>2020-07-27 16:35:47 +0000
commite1a1c8e7de5e10fa64d168dc5d35a80b96767395 (patch)
treec0057448e323c730bea2c76cecf9efb85ef14181 /test/formatter_test.exs
parent4a6389316dac53c1ca2ec36d160690476d881185 (diff)
parent2a3abfd326f0cbb588dfe66a23e9783be3038a5e (diff)
downloadpleroma-e1a1c8e7de5e10fa64d168dc5d35a80b96767395.tar.gz
pleroma-e1a1c8e7de5e10fa64d168dc5d35a80b96767395.zip
Merge branch 'develop' into 'cleanup/masto_fe-default_settings'
# Conflicts: # lib/pleroma/web/views/masto_fe_view.ex
Diffstat (limited to 'test/formatter_test.exs')
-rw-r--r--test/formatter_test.exs31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/formatter_test.exs b/test/formatter_test.exs
index bef5a2c28..f066bd50a 100644
--- a/test/formatter_test.exs
+++ b/test/formatter_test.exs
@@ -10,6 +10,7 @@ defmodule Pleroma.FormatterTest do
import Pleroma.Factory
setup_all do
+ clear_config(Pleroma.Formatter)
Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
:ok
end
@@ -255,6 +256,36 @@ defmodule Pleroma.FormatterTest do
assert {_text, ^expected_mentions, []} = Formatter.linkify(text)
end
+
+ test "it parses URL containing local mention" do
+ _user = insert(:user, %{nickname: "lain"})
+
+ text = "https://example.com/@lain"
+
+ expected = ~S(<a href="https://example.com/@lain" rel="ugc">https://example.com/@lain</a>)
+
+ assert {^expected, [], []} = Formatter.linkify(text)
+ end
+
+ test "it correctly parses angry face D:< with mention" do
+ lain =
+ insert(:user, %{
+ nickname: "lain@lain.com",
+ ap_id: "https://lain.com/users/lain",
+ id: "9qrWmR0cKniB0YU0TA"
+ })
+
+ text = "@lain@lain.com D:<"
+
+ expected_text =
+ ~S(<span class="h-card"><a class="u-url mention" data-user="9qrWmR0cKniB0YU0TA" href="https://lain.com/users/lain" rel="ugc">@<span>lain</span></a></span> D:<)
+
+ expected_mentions = [
+ {"@lain@lain.com", lain}
+ ]
+
+ assert {^expected_text, ^expected_mentions, []} = Formatter.linkify(text)
+ end
end
describe ".parse_tags" do