summaryrefslogtreecommitdiff
path: root/test/web/activity_pub/object_validator_test.exs
diff options
context:
space:
mode:
authorRoman Chvanikov <chvanikoff@pm.me>2020-05-09 11:31:34 +0300
committerRoman Chvanikov <chvanikoff@pm.me>2020-05-09 11:31:34 +0300
commit942093683a1e6b3f3d3692268b2af8390da6d325 (patch)
tree3ad22c9d4d06716f469925b7c15a30e9f0e25c57 /test/web/activity_pub/object_validator_test.exs
parentcbe383ae832f13d5d2a20ee8fb5e85498205fbc3 (diff)
parentc962c6afb3b30eb6d42c2a5548898b3713492169 (diff)
downloadpleroma-942093683a1e6b3f3d3692268b2af8390da6d325.tar.gz
pleroma-942093683a1e6b3f3d3692268b2af8390da6d325.zip
Merge branch 'develop' into feature/admin-api-status-count-per-instance
Diffstat (limited to 'test/web/activity_pub/object_validator_test.exs')
-rw-r--r--test/web/activity_pub/object_validator_test.exs40
1 files changed, 40 insertions, 0 deletions
diff --git a/test/web/activity_pub/object_validator_test.exs b/test/web/activity_pub/object_validator_test.exs
index 174be5ec6..f382adf3e 100644
--- a/test/web/activity_pub/object_validator_test.exs
+++ b/test/web/activity_pub/object_validator_test.exs
@@ -10,6 +10,46 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidatorTest do
import Pleroma.Factory
+ describe "EmojiReacts" do
+ setup do
+ user = insert(:user)
+ {:ok, post_activity} = CommonAPI.post(user, %{"status" => "uguu"})
+
+ object = Pleroma.Object.get_by_ap_id(post_activity.data["object"])
+
+ {:ok, valid_emoji_react, []} = Builder.emoji_react(user, object, "👌")
+
+ %{user: user, post_activity: post_activity, valid_emoji_react: valid_emoji_react}
+ end
+
+ test "it validates a valid EmojiReact", %{valid_emoji_react: valid_emoji_react} do
+ assert {:ok, _, _} = ObjectValidator.validate(valid_emoji_react, [])
+ end
+
+ test "it is not valid without a 'content' field", %{valid_emoji_react: valid_emoji_react} do
+ without_content =
+ valid_emoji_react
+ |> Map.delete("content")
+
+ {:error, cng} = ObjectValidator.validate(without_content, [])
+
+ refute cng.valid?
+ assert {:content, {"can't be blank", [validation: :required]}} in cng.errors
+ end
+
+ test "it is not valid with a non-emoji content field", %{valid_emoji_react: valid_emoji_react} do
+ without_emoji_content =
+ valid_emoji_react
+ |> Map.put("content", "x")
+
+ {:error, cng} = ObjectValidator.validate(without_emoji_content, [])
+
+ refute cng.valid?
+
+ assert {:content, {"must be a single character emoji", []}} in cng.errors
+ end
+ end
+
describe "Undos" do
setup do
user = insert(:user)