1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.ActivityPub.ObjectViewTest do
10 alias Pleroma.Web.ActivityPub.ObjectView
11 alias Pleroma.Web.CommonAPI
13 test "renders a note object" do
16 result = ObjectView.render("object.json", %{object: note})
18 assert result["id"] == note.data["id"]
19 assert result["to"] == note.data["to"]
20 assert result["content"] == note.data["content"]
21 assert result["type"] == "Note"
22 assert result["@context"]
25 test "renders a note activity" do
26 note = insert(:note_activity)
27 object = Object.normalize(note)
29 result = ObjectView.render("object.json", %{object: note})
31 assert result["id"] == note.data["id"]
32 assert result["to"] == note.data["to"]
33 assert result["object"]["type"] == "Note"
34 assert result["object"]["content"] == object.data["content"]
35 assert result["type"] == "Create"
36 assert result["@context"]
39 test "renders a like activity" do
40 note = insert(:note_activity)
41 object = Object.normalize(note)
44 {:ok, like_activity, _} = CommonAPI.favorite(note.id, user)
46 result = ObjectView.render("object.json", %{object: like_activity})
48 assert result["id"] == like_activity.data["id"]
49 assert result["object"] == object.data["id"]
50 assert result["type"] == "Like"
53 test "renders an announce activity" do
54 note = insert(:note_activity)
55 object = Object.normalize(note)
58 {:ok, announce_activity, _} = CommonAPI.repeat(note.id, user)
60 result = ObjectView.render("object.json", %{object: announce_activity})
62 assert result["id"] == announce_activity.data["id"]
63 assert result["object"] == object.data["id"]
64 assert result["type"] == "Announce"