Merge branch 'develop' of git.pleroma.social:pleroma/pleroma into feature/expire...
[akkoma] / test / pleroma / web / activity_pub / mrf / no_placeholder_text_policy_test.exs
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
5 defmodule Pleroma.Web.ActivityPub.MRF.NoPlaceholderTextPolicyTest do
6 use Pleroma.DataCase
7 alias Pleroma.Web.ActivityPub.MRF.NoPlaceholderTextPolicy
8
9 test "it clears content object" do
10 message = %{
11 "type" => "Create",
12 "object" => %{"content" => ".", "attachment" => "image"}
13 }
14
15 assert {:ok, res} = NoPlaceholderTextPolicy.filter(message)
16 assert res["object"]["content"] == ""
17
18 message = put_in(message, ["object", "content"], "<p>.</p>")
19 assert {:ok, res} = NoPlaceholderTextPolicy.filter(message)
20 assert res["object"]["content"] == ""
21 end
22
23 @messages [
24 %{
25 "type" => "Create",
26 "object" => %{"content" => "test", "attachment" => "image"}
27 },
28 %{"type" => "Create", "object" => %{"content" => "."}},
29 %{"type" => "Create", "object" => %{"content" => "<p>.</p>"}}
30 ]
31 test "it skips filter" do
32 Enum.each(@messages, fn message ->
33 assert {:ok, res} = NoPlaceholderTextPolicy.filter(message)
34 assert res == message
35 end)
36 end
37 end