forked from AkkomaGang/akkoma
add extra tests for builder
This commit is contained in:
parent
1c7d7845c3
commit
f6304cfd78
2 changed files with 58 additions and 0 deletions
|
@ -188,6 +188,11 @@ def emoji_url(%{"type" => "EmojiReact", "content" => emoji, "tag" => tags}) do
|
|||
|
||||
def emoji_url(_), do: nil
|
||||
|
||||
def emoji_name_with_instance(name, url) do
|
||||
url = url |> URI.parse() |> Map.get(:host)
|
||||
"#{name}@#{url}"
|
||||
end
|
||||
|
||||
emoji_qualification_map =
|
||||
emojis
|
||||
|> Enum.filter(&String.contains?(&1, "\uFE0F"))
|
||||
|
|
|
@ -48,4 +48,57 @@ test "returns note data" do
|
|||
assert {:ok, ^expected, []} = Builder.note(draft)
|
||||
end
|
||||
end
|
||||
|
||||
describe "emoji_react/1" do
|
||||
test "unicode emoji" do
|
||||
user = insert(:user)
|
||||
note = insert(:note)
|
||||
|
||||
assert {:ok, %{"content" => "👍", "type" => "EmojiReact"}, []} =
|
||||
Builder.emoji_react(user, note, "👍")
|
||||
end
|
||||
|
||||
test "custom emoji" do
|
||||
user = insert(:user)
|
||||
note = insert(:note)
|
||||
|
||||
assert {:ok,
|
||||
%{
|
||||
"content" => ":dinosaur:",
|
||||
"type" => "EmojiReact",
|
||||
"tag" => [
|
||||
%{
|
||||
"name" => ":dinosaur:",
|
||||
"id" => "http://localhost:4001/emoji/dino walking.gif",
|
||||
"icon" => %{
|
||||
"type" => "Image",
|
||||
"url" => "http://localhost:4001/emoji/dino walking.gif"
|
||||
}
|
||||
}
|
||||
]
|
||||
}, []} = Builder.emoji_react(user, note, ":dinosaur:")
|
||||
end
|
||||
|
||||
test "remote custom emoji" do
|
||||
user = insert(:user)
|
||||
other_user = insert(:user, local: false)
|
||||
note = insert(:note, data: %{"reactions" => [["wow", [other_user.ap_id], "https://remote/emoji/wow"]]})
|
||||
|
||||
assert {:ok,
|
||||
%{
|
||||
"content" => ":wow:",
|
||||
"type" => "EmojiReact",
|
||||
"tag" => [
|
||||
%{
|
||||
"name" => ":wow:",
|
||||
"id" => "https://remote/emoji/wow",
|
||||
"icon" => %{
|
||||
"type" => "Image",
|
||||
"url" => "https://remote/emoji/wow"
|
||||
}
|
||||
}
|
||||
]
|
||||
}, []} = Builder.emoji_react(user, note, ":wow@remote:")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue