logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma

no_placeholder_text_policy_test.exs (1177B)


  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.Web.ActivityPub.MRF.NoPlaceholderTextPolicyTest do
  5. use Pleroma.DataCase
  6. alias Pleroma.Web.ActivityPub.MRF.NoPlaceholderTextPolicy
  7. test "it clears content object" do
  8. message = %{
  9. "type" => "Create",
  10. "object" => %{"content" => ".", "attachment" => "image"}
  11. }
  12. assert {:ok, res} = NoPlaceholderTextPolicy.filter(message)
  13. assert res["object"]["content"] == ""
  14. message = put_in(message, ["object", "content"], "<p>.</p>")
  15. assert {:ok, res} = NoPlaceholderTextPolicy.filter(message)
  16. assert res["object"]["content"] == ""
  17. end
  18. @messages [
  19. %{
  20. "type" => "Create",
  21. "object" => %{"content" => "test", "attachment" => "image"}
  22. },
  23. %{"type" => "Create", "object" => %{"content" => "."}},
  24. %{"type" => "Create", "object" => %{"content" => "<p>.</p>"}}
  25. ]
  26. test "it skips filter" do
  27. Enum.each(@messages, fn message ->
  28. assert {:ok, res} = NoPlaceholderTextPolicy.filter(message)
  29. assert res == message
  30. end)
  31. end
  32. end