Merge branch 'mastofe-content-types' into 'develop'
[akkoma] / test / web / activity_pub / views / object_view_test.exs
1 defmodule Pleroma.Web.ActivityPub.ObjectViewTest do
2 use Pleroma.DataCase
3 import Pleroma.Factory
4
5 alias Pleroma.Web.ActivityPub.ObjectView
6 alias Pleroma.Web.CommonAPI
7
8 test "renders a note object" do
9 note = insert(:note)
10
11 result = ObjectView.render("object.json", %{object: note})
12
13 assert result["id"] == note.data["id"]
14 assert result["to"] == note.data["to"]
15 assert result["content"] == note.data["content"]
16 assert result["type"] == "Note"
17 assert result["@context"]
18 end
19
20 test "renders a note activity" do
21 note = insert(:note_activity)
22
23 result = ObjectView.render("object.json", %{object: note})
24
25 assert result["id"] == note.data["id"]
26 assert result["to"] == note.data["to"]
27 assert result["object"]["type"] == "Note"
28 assert result["object"]["content"] == note.data["object"]["content"]
29 assert result["type"] == "Create"
30 assert result["@context"]
31 end
32
33 test "renders a like activity" do
34 note = insert(:note_activity)
35 user = insert(:user)
36
37 {:ok, like_activity, _} = CommonAPI.favorite(note.id, user)
38
39 result = ObjectView.render("object.json", %{object: like_activity})
40
41 assert result["id"] == like_activity.data["id"]
42 assert result["object"] == note.data["object"]["id"]
43 assert result["type"] == "Like"
44 end
45
46 test "renders an announce activity" do
47 note = insert(:note_activity)
48 user = insert(:user)
49
50 {:ok, announce_activity, _} = CommonAPI.repeat(note.id, user)
51
52 result = ObjectView.render("object.json", %{object: announce_activity})
53
54 assert result["id"] == announce_activity.data["id"]
55 assert result["object"] == note.data["object"]["id"]
56 assert result["type"] == "Announce"
57 end
58 end