- assert length(subs) == 3
- Enum.each(subs, fn {uuid, _} -> assert String.contains?(text, uuid) end)
+ expected_text =
+ "<span class='h-card'><a data-user='#{gsimg.id}' class='u-url mention' href='#{
+ gsimg.ap_id
+ }'>@<span>gsimg</span></a></span> According to <span class='h-card'><a data-user='#{
+ archaeme.id
+ }' class='u-url mention' href='#{"https://archeme/@archa_eme_"}'>@<span>archa_eme_</span></a></span>, that is @daggsy. Also hello <span class='h-card'><a data-user='#{
+ archaeme_remote.id
+ }' class='u-url mention' href='#{archaeme_remote.ap_id}'>@<span>archaeme</span></a></span>"
+
+ assert expected_text == text
+ end
+
+ test "gives a replacement for user links when the user is using Osada" do
+ {:ok, mike} = User.get_or_fetch("mike@osada.macgirvin.com")
+
+ text = "@mike@osada.macgirvin.com test"
+
+ {text, mentions, []} = Formatter.linkify(text)
+
+ assert length(mentions) == 1
+
+ expected_text =
+ "<span class='h-card'><a data-user='#{mike.id}' class='u-url mention' href='#{mike.ap_id}'>@<span>mike</span></a></span> test"
+
+ assert expected_text == text
+ end
+
+ test "gives a replacement for single-character local nicknames" do
+ text = "@o hi"
+ o = insert(:user, %{nickname: "o"})
+
+ {text, mentions, []} = Formatter.linkify(text)
+
+ assert length(mentions) == 1