1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.Metadata.UtilsTest do
6 use Pleroma.DataCase, async: false
8 alias Pleroma.Web.Metadata.Utils
10 describe "scrub_html_and_truncate/1" do
11 test "it returns text without encode HTML" do
17 "actor" => user.ap_id,
18 "id" => "https://pleroma.gov/objects/whatever",
19 "content" => "Pleroma's really cool!"
23 assert Utils.scrub_html_and_truncate(note) == "Pleroma's really cool!"
26 test "it does not return old content after editing" do
29 {:ok, activity} = Pleroma.Web.CommonAPI.post(user, %{status: "mew mew #def"})
31 object = Pleroma.Object.normalize(activity)
32 assert Utils.scrub_html_and_truncate(object) == "mew mew #def"
34 {:ok, update} = Pleroma.Web.CommonAPI.update(user, activity, %{status: "mew mew #abc"})
35 update = Pleroma.Activity.normalize(update)
36 object = Pleroma.Object.normalize(update)
37 assert Utils.scrub_html_and_truncate(object) == "mew mew #abc"
41 describe "scrub_html_and_truncate/2" do
42 test "it returns text without encode HTML" do
43 assert Utils.scrub_html_and_truncate("Pleroma's really cool!") == "Pleroma's really cool!"