Merge branch 'fix/tusky-dm' into 'develop'
[akkoma] / test / web / activity_pub / utils_test.exs
1 defmodule Pleroma.Web.ActivityPub.UtilsTest do
2 use Pleroma.DataCase
3 alias Pleroma.Web.ActivityPub.Utils
4
5 describe "determine_explicit_mentions()" do
6 test "works with an object that has mentions" do
7 object = %{
8 "tag" => [
9 %{
10 "type" => "Mention",
11 "href" => "https://example.com/~alyssa",
12 "name" => "Alyssa P. Hacker"
13 }
14 ]
15 }
16
17 assert Utils.determine_explicit_mentions(object) == ["https://example.com/~alyssa"]
18 end
19
20 test "works with an object that does not have mentions" do
21 object = %{
22 "tag" => [
23 %{"type" => "Hashtag", "href" => "https://example.com/tag/2hu", "name" => "2hu"}
24 ]
25 }
26
27 assert Utils.determine_explicit_mentions(object) == []
28 end
29
30 test "works with an object that has mentions and other tags" do
31 object = %{
32 "tag" => [
33 %{
34 "type" => "Mention",
35 "href" => "https://example.com/~alyssa",
36 "name" => "Alyssa P. Hacker"
37 },
38 %{"type" => "Hashtag", "href" => "https://example.com/tag/2hu", "name" => "2hu"}
39 ]
40 }
41
42 assert Utils.determine_explicit_mentions(object) == ["https://example.com/~alyssa"]
43 end
44
45 test "works with an object that has no tags" do
46 object = %{}
47
48 assert Utils.determine_explicit_mentions(object) == []
49 end
50
51 test "works with an object that has only IR tags" do
52 object = %{"tag" => ["2hu"]}
53
54 assert Utils.determine_explicit_mentions(object) == []
55 end
56 end
57 end