tests: add a testcase for matching osada users in the formatter
[akkoma] / test / formatter_test.exs
index e37b17879565300b411870c51a95c4f593f89571..13084baa79bb65cd9d1823d0c929f9f5d08f623f 100644 (file)
@@ -1,5 +1,6 @@
 defmodule Pleroma.FormatterTest do
   alias Pleroma.Formatter
+  alias Pleroma.User
   use Pleroma.DataCase
 
   import Pleroma.Factory
@@ -131,6 +132,24 @@ defmodule Pleroma.FormatterTest do
       assert expected_text == Formatter.finalize({subs, text})
     end
 
+    test "gives a replacement for user links when the user is using Osada" do
+      mike = User.get_or_fetch("mike@osada.macgirvin.com")
+
+      text = "@mike@osada.macgirvin.com test"
+
+      mentions = Formatter.parse_mentions(text)
+
+      {subs, text} = Formatter.add_user_links({[], text}, mentions)
+
+      assert length(subs) == 1
+      Enum.each(subs, fn {uuid, _} -> assert String.contains?(text, uuid) end)
+
+      expected_text =
+        "<span><a class='mention' href='#{mike.ap_id}'>@<span>mike</span></a></span> test"
+
+      assert expected_text == Formatter.finalize({subs, text})
+    end
+
     test "gives a replacement for single-character local nicknames" do
       text = "@o hi"
       o = insert(:user, %{nickname: "o"})