summaryrefslogtreecommitdiff
path: root/test/web/activity_pub/utils_test.exs
diff options
context:
space:
mode:
authorlain <lain@soykaf.club>2019-01-23 13:05:58 +0100
committerlain <lain@soykaf.club>2019-01-23 13:05:58 +0100
commit2de208817c04d9a48aaf0fdaf887dd0e10d15907 (patch)
tree38cf094a6405c147fe5d8cff3be173f2379166d9 /test/web/activity_pub/utils_test.exs
parent7390192c03248ff18eff19d555f28300a7b07e09 (diff)
parentb624b7a150c813722c4ffe82112c03e246fb5760 (diff)
downloadpleroma-2de208817c04d9a48aaf0fdaf887dd0e10d15907.tar.gz
pleroma-2de208817c04d9a48aaf0fdaf887dd0e10d15907.zip
Merge branch 'develop' into rename/pleroma_activity_consistency
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