640caa2b64c71899fd9cb099abf43c7d6548fd5f
[akkoma] / test / pleroma / web / activity_pub / builder_test.exs
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.ActivityPub.BuilderTest do
6 alias Pleroma.Web.ActivityPub.Builder
7 alias Pleroma.Web.CommonAPI.ActivityDraft
8 use Pleroma.DataCase
9
10 import Pleroma.Factory
11
12 describe "note/1" do
13 test "returns note data" do
14 user = insert(:user)
15 note = insert(:note)
16 quote = insert(:note)
17 user2 = insert(:user)
18 user3 = insert(:user)
19
20 draft = %ActivityDraft{
21 user: user,
22 to: [user2.ap_id],
23 context: "2hu",
24 content_html: "<h1>This is :moominmamma: note</h1>",
25 in_reply_to: note.id,
26 tags: [name: "jimm"],
27 summary: "test summary",
28 cc: [user3.ap_id],
29 extra: %{"custom_tag" => "test"},
30 quote: quote
31 }
32
33 expected = %{
34 "actor" => user.ap_id,
35 "attachment" => [],
36 "cc" => [user3.ap_id],
37 "content" => "<h1>This is :moominmamma: note</h1>",
38 "context" => "2hu",
39 "sensitive" => false,
40 "summary" => "test summary",
41 "tag" => ["jimm"],
42 "to" => [user2.ap_id],
43 "type" => "Note",
44 "custom_tag" => "test",
45 "quoteUri" => quote.data["id"]
46 }
47
48 assert {:ok, ^expected, []} = Builder.note(draft)
49 end
50 end
51 end