1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.ActivityPub.BuilderTest do
6 alias Pleroma.Web.ActivityPub.Builder
7 alias Pleroma.Web.CommonAPI.ActivityDraft
10 import Pleroma.Factory
13 test "returns note data" do
20 draft = %ActivityDraft{
24 content_html: "<h1>This is :moominmamma: note</h1>",
27 summary: "test summary",
29 extra: %{"custom_tag" => "test"},
34 "actor" => user.ap_id,
36 "cc" => [user3.ap_id],
37 "content" => "<h1>This is :moominmamma: note</h1>",
40 "summary" => "test summary",
42 "to" => [user2.ap_id],
44 "custom_tag" => "test",
45 "quoteUri" => quote.data["id"]
48 assert {:ok, ^expected, []} = Builder.note(draft)
52 describe "emoji_react/1" do
53 test "unicode emoji" do
57 assert {:ok, %{"content" => "👍", "type" => "EmojiReact"}, []} =
58 Builder.emoji_react(user, note, "👍")
61 test "custom emoji" do
67 "content" => ":dinosaur:",
68 "type" => "EmojiReact",
71 "name" => ":dinosaur:",
72 "id" => "http://localhost:4001/emoji/dino walking.gif",
75 "url" => "http://localhost:4001/emoji/dino walking.gif"
79 }, []} = Builder.emoji_react(user, note, ":dinosaur:")
82 test "remote custom emoji" do
84 other_user = insert(:user, local: false)
88 data: %{"reactions" => [["wow", [other_user.ap_id], "https://remote/emoji/wow"]]}
94 "type" => "EmojiReact",
98 "id" => "https://remote/emoji/wow",
101 "url" => "https://remote/emoji/wow"
105 }, []} = Builder.emoji_react(user, note, ":wow@remote:")