Merge branch 'linkify' into 'develop'
[akkoma] / test / formatter_test.exs
index bef5a2c28813b045cf8ba07cdc9ae84691140d65..8713ab9c22fbefdb4d761e6f62a610280f99e325 100644 (file)
@@ -255,6 +255,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