diff --git a/test/pleroma/web/metadata/utils_test.exs b/test/pleroma/web/metadata/utils_test.exs index 9d94bf9ca..1fe211d2f 100644 --- a/test/pleroma/web/metadata/utils_test.exs +++ b/test/pleroma/web/metadata/utils_test.exs @@ -8,7 +8,7 @@ defmodule Pleroma.Web.Metadata.UtilsTest do alias Pleroma.Web.Metadata.Utils describe "filter_html_and_truncate/1" do - test "it returns text without HTML" do + test "it returns text without encoded HTML entities" do user = insert(:user) note = @@ -38,10 +38,42 @@ defmodule Pleroma.Web.Metadata.UtilsTest do assert Utils.filter_html_and_truncate(note) == "First line Second line" end + + test "it strips emojis" do + user = insert(:user) + + note = + insert(:note, %{ + data: %{ + "actor" => user.ap_id, + "id" => "https://pleroma.gov/objects/whatever", + "content" => "Mozilla Firefox :firefox:" + } + }) + + assert Utils.filter_html_and_truncate(note) == + "Mozilla Firefox" + end + + test "it strips HTML tags and other entities" do + user = insert(:user) + + note = + insert(:note, %{ + data: %{ + "actor" => user.ap_id, + "id" => "https://pleroma.gov/objects/whatever", + "content" => "
and a paragraph!
" + } + }) + + assert Utils.filter_html_and_truncate(note) == + "my title and a paragraph!" + end end describe "scrub_html_and_truncate/2" do - test "it returns text without encode HTML" do + test "it returns text without encoded HTML entities" do assert Utils.scrub_html_and_truncate("Pleroma's really cool!") == "Pleroma's really cool!" end