More tests for filter_html_and_truncate/1

This commit is contained in:
Mark Felder 2021-06-11 16:04:06 -05:00
parent bb4ced0eb5
commit 04b5f19a14

View File

@ -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" => "<title>my title</title> <p>and a paragraph&#33;</p>"
}
})
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