X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;ds=sidebyside;f=test%2Fformatter_test.exs;h=bfa673049843bcc779d249cd6dc16925eb4ac04f;hb=c34126f89ca58141cc927bddc2474bef76ea1575;hp=5e70111605f3f738152d662035153bc0d39264c1;hpb=3e5301ad5cf3d9805c0dc9ea8440992de160330b;p=akkoma
diff --git a/test/formatter_test.exs b/test/formatter_test.exs
index 5e7011160..bfa673049 100644
--- a/test/formatter_test.exs
+++ b/test/formatter_test.exs
@@ -184,17 +184,19 @@ defmodule Pleroma.FormatterTest do
test "given the 'safe_mention' option, it will only mention people in the beginning" do
user = insert(:user)
- _other_user = insert(:user)
+ other_user = insert(:user)
third_user = insert(:user)
- text = " @#{user.nickname} hey dude i hate @#{third_user.nickname}"
+ text = " @#{user.nickname} @#{other_user.nickname} hey dudes i hate @#{third_user.nickname}"
{expected_text, mentions, [] = _tags} = Formatter.linkify(text, safe_mention: true)
- assert mentions == [{"@#{user.nickname}", user}]
+ assert mentions == [{"@#{user.nickname}", user}, {"@#{other_user.nickname}", other_user}]
assert expected_text ==
"@#{user.nickname} hey dude i hate @#{user.nickname} @#{other_user.nickname} hey dudes i hate @#{third_user.nickname}"
end
@@ -206,6 +208,15 @@ defmodule Pleroma.FormatterTest do
assert mentions == []
assert expected_text == text
end
+
+ test "given the 'safe_mention' option, it will keep text after newlines" do
+ user = insert(:user)
+ text = " @#{user.nickname}\n hey dude\n\nhow are you doing?"
+
+ {expected_text, _, _} = Formatter.linkify(text, safe_mention: true)
+
+ assert expected_text =~ "how are you doing?"
+ end
end
describe ".parse_tags" do