diff options
author | Haelwenn (lanodan) Monnier <contact@hacktivis.me> | 2020-07-31 13:57:21 +0200 |
---|---|---|
committer | Haelwenn (lanodan) Monnier <contact@hacktivis.me> | 2020-07-31 13:57:21 +0200 |
commit | ac2598307d15bd833310f6c5cfadc218b7d80480 (patch) | |
tree | edbc9f8750414dad4f43a2c88c348438c6900616 /test/formatter_test.exs | |
parent | e4beff90f5670876184b2593c1b4a49f2339d048 (diff) | |
parent | a6d3bb5f30697cafc5dd9acf490bde7e2f33f5f8 (diff) | |
download | pleroma-ac2598307d15bd833310f6c5cfadc218b7d80480.tar.gz pleroma-ac2598307d15bd833310f6c5cfadc218b7d80480.zip |
Merge remote-tracking branch 'pleroma/develop' into features/poll-validation
Diffstat (limited to 'test/formatter_test.exs')
-rw-r--r-- | test/formatter_test.exs | 31 |
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 |