3fe32bce5d24e3852500d1ec2257e4269d3f5d86
[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 user2 = insert(:user)
17 user3 = insert(:user)
18
19 draft = %ActivityDraft{
20 user: user,
21 to: [user2.ap_id],
22 context: "2hu",
23 content_html: "<h1>This is :moominmamma: note</h1>",
24 in_reply_to: note.id,
25 tags: [name: "jimm"],
26 summary: "test summary",
27 cc: [user3.ap_id],
28 extra: %{"custom_tag" => "test"}
29 }
30
31 expected = %{
32 "actor" => user.ap_id,
33 "attachment" => [],
34 "cc" => [user3.ap_id],
35 "content" => "<h1>This is :moominmamma: note</h1>",
36 "context" => "2hu",
37 "sensitive" => false,
38 "summary" => "test summary",
39 "tag" => ["jimm"],
40 "to" => [user2.ap_id],
41 "type" => "Note",
42 "custom_tag" => "test"
43 }
44
45 assert {:ok, ^expected, []} = Builder.note(draft)
46 end
47 end
48 end