Merge branch 'develop' of https://git.pleroma.social/pleroma/pleroma into develop
[akkoma] / test / formatter_test.exs
index 3bff51527592882801175372cbcab1f91b68d137..37f8bb80075cd9ebd03beb4a18d8e671e9a5f93a 100644 (file)
@@ -119,16 +119,29 @@ defmodule Pleroma.FormatterTest do
     end
   end
 
-  describe "add_user_links" do
+  describe "Formatter.linkify" do
+    test "correctly finds mentions that contain the domain name" do
+      _user = insert(:user, %{nickname: "lain"})
+      _remote_user = insert(:user, %{nickname: "lain@lain.com", local: false})
+
+      text = "hey @lain@lain.com what's up"
+
+      {_text, mentions, []} = Formatter.linkify(text)
+      [{username, user}] = mentions
+
+      assert username == "@lain@lain.com"
+      assert user.nickname == "lain@lain.com"
+    end
+
     test "gives a replacement for user links, using local nicknames in user links text" do
       text = "@gsimg According to @archa_eme_, that is @daggsy. Also hello @archaeme@archae.me"
       gsimg = insert(:user, %{nickname: "gsimg"})
 
       archaeme =
-        insert(:user, %{
+        insert(:user,
           nickname: "archa_eme_",
-          info: %User.Info{source_data: %{"url" => "https://archeme/@archa_eme_"}}
-        })
+          source_data: %{"url" => "https://archeme/@archa_eme_"}
+        )
 
       archaeme_remote = insert(:user, %{nickname: "archaeme@archae.me"})