More tests for filter_html_and_truncate/1
This commit is contained in:
parent
bb4ced0eb5
commit
04b5f19a14
@ -8,7 +8,7 @@ defmodule Pleroma.Web.Metadata.UtilsTest do
|
|||||||
alias Pleroma.Web.Metadata.Utils
|
alias Pleroma.Web.Metadata.Utils
|
||||||
|
|
||||||
describe "filter_html_and_truncate/1" do
|
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)
|
user = insert(:user)
|
||||||
|
|
||||||
note =
|
note =
|
||||||
@ -38,10 +38,42 @@ defmodule Pleroma.Web.Metadata.UtilsTest do
|
|||||||
assert Utils.filter_html_and_truncate(note) ==
|
assert Utils.filter_html_and_truncate(note) ==
|
||||||
"First line Second line"
|
"First line Second line"
|
||||||
end
|
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!</p>"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
assert Utils.filter_html_and_truncate(note) ==
|
||||||
|
"my title and a paragraph!"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "scrub_html_and_truncate/2" do
|
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!"
|
assert Utils.scrub_html_and_truncate("Pleroma's really cool!") == "Pleroma's really cool!"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user