Formatter: Add a test for domain / username clashes

This commit is contained in:
lain 2020-01-28 13:38:21 +01:00
parent b12f306473
commit 51283bf996
1 changed files with 14 additions and 1 deletions

View File

@ -119,7 +119,20 @@ test "turning urls into links" do
end end
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 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" text = "@gsimg According to @archa_eme_, that is @daggsy. Also hello @archaeme@archae.me"
gsimg = insert(:user, %{nickname: "gsimg"}) gsimg = insert(:user, %{nickname: "gsimg"})