summaryrefslogtreecommitdiff
path: root/test/web/activity_pub/utils_test.exs
diff options
context:
space:
mode:
authorkaniini <nenolod@gmail.com>2019-01-25 05:00:47 +0000
committerkaniini <nenolod@gmail.com>2019-01-25 05:00:47 +0000
commitc9b418e5477229017b3750c55cf3ea3d03b7e609 (patch)
treed1b458bea76ff3ec296897de405f9e3c8578f897 /test/web/activity_pub/utils_test.exs
parent44693fbf6e5c5ec5622207e263688e3af7d1a83a (diff)
parent4df71cd88b2725f1838c2899b3078a74dbb0c33f (diff)
downloadpleroma-c9b418e5477229017b3750c55cf3ea3d03b7e609.tar.gz
pleroma-c9b418e5477229017b3750c55cf3ea3d03b7e609.zip
Merge branch 'develop' into 'oembed_provider'
# Conflicts: # lib/pleroma/activity.ex
Diffstat (limited to 'test/web/activity_pub/utils_test.exs')
-rw-r--r--test/web/activity_pub/utils_test.exs57
1 files changed, 57 insertions, 0 deletions
diff --git a/test/web/activity_pub/utils_test.exs b/test/web/activity_pub/utils_test.exs
new file mode 100644
index 000000000..aeed0564c
--- /dev/null
+++ b/test/web/activity_pub/utils_test.exs
@@ -0,0 +1,57 @@
+defmodule Pleroma.Web.ActivityPub.UtilsTest do
+ use Pleroma.DataCase
+ alias Pleroma.Web.ActivityPub.Utils
+
+ describe "determine_explicit_mentions()" do
+ test "works with an object that has mentions" do
+ object = %{
+ "tag" => [
+ %{
+ "type" => "Mention",
+ "href" => "https://example.com/~alyssa",
+ "name" => "Alyssa P. Hacker"
+ }
+ ]
+ }
+
+ assert Utils.determine_explicit_mentions(object) == ["https://example.com/~alyssa"]
+ end
+
+ test "works with an object that does not have mentions" do
+ object = %{
+ "tag" => [
+ %{"type" => "Hashtag", "href" => "https://example.com/tag/2hu", "name" => "2hu"}
+ ]
+ }
+
+ assert Utils.determine_explicit_mentions(object) == []
+ end
+
+ test "works with an object that has mentions and other tags" do
+ object = %{
+ "tag" => [
+ %{
+ "type" => "Mention",
+ "href" => "https://example.com/~alyssa",
+ "name" => "Alyssa P. Hacker"
+ },
+ %{"type" => "Hashtag", "href" => "https://example.com/tag/2hu", "name" => "2hu"}
+ ]
+ }
+
+ assert Utils.determine_explicit_mentions(object) == ["https://example.com/~alyssa"]
+ end
+
+ test "works with an object that has no tags" do
+ object = %{}
+
+ assert Utils.determine_explicit_mentions(object) == []
+ end
+
+ test "works with an object that has only IR tags" do
+ object = %{"tag" => ["2hu"]}
+
+ assert Utils.determine_explicit_mentions(object) == []
+ end
+ end
+end