diff options
author | lambda <pleromagit@rogerbraun.net> | 2019-01-21 12:35:10 +0000 |
---|---|---|
committer | lambda <pleromagit@rogerbraun.net> | 2019-01-21 12:35:10 +0000 |
commit | 69454c834519a68b80318ad0efecd682a1013cda (patch) | |
tree | a043857a7d01354dae10e5ef2a29bfbb3e43f53e /test/web/activity_pub/utils_test.exs | |
parent | 52006f8f8a9e71f7444b6849ba01c4fef69745d7 (diff) | |
parent | aa37313416c155a37b40e09617eb2fe524edbf0b (diff) | |
download | pleroma-69454c834519a68b80318ad0efecd682a1013cda.tar.gz pleroma-69454c834519a68b80318ad0efecd682a1013cda.zip |
Merge branch 'feature/dm-sanity' into 'develop'
DM sanitization
See merge request pleroma/pleroma!458
Diffstat (limited to 'test/web/activity_pub/utils_test.exs')
-rw-r--r-- | test/web/activity_pub/utils_test.exs | 57 |
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 |