Merge branch 'feature/770-add-emoji-tags' into 'develop'
Feature/770 add emoji tags See merge request pleroma/pleroma!998
This commit is contained in:
commit
23067908de
15 changed files with 270 additions and 28 deletions
106
test/emoji_test.exs
Normal file
106
test/emoji_test.exs
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
defmodule Pleroma.EmojiTest do
|
||||
use ExUnit.Case, async: true
|
||||
alias Pleroma.Emoji
|
||||
|
||||
describe "get_all/0" do
|
||||
setup do
|
||||
emoji_list = Emoji.get_all()
|
||||
{:ok, emoji_list: emoji_list}
|
||||
end
|
||||
|
||||
test "first emoji", %{emoji_list: emoji_list} do
|
||||
[emoji | _others] = emoji_list
|
||||
{code, path, tags} = emoji
|
||||
|
||||
assert tuple_size(emoji) == 3
|
||||
assert is_binary(code)
|
||||
assert is_binary(path)
|
||||
assert is_binary(tags)
|
||||
end
|
||||
|
||||
test "random emoji", %{emoji_list: emoji_list} do
|
||||
emoji = Enum.random(emoji_list)
|
||||
{code, path, tags} = emoji
|
||||
|
||||
assert tuple_size(emoji) == 3
|
||||
assert is_binary(code)
|
||||
assert is_binary(path)
|
||||
assert is_binary(tags)
|
||||
end
|
||||
end
|
||||
|
||||
describe "match_extra/2" do
|
||||
setup do
|
||||
groups = [
|
||||
"list of files": ["/emoji/custom/first_file.png", "/emoji/custom/second_file.png"],
|
||||
"wildcard folder": "/emoji/custom/*/file.png",
|
||||
"wildcard files": "/emoji/custom/folder/*.png",
|
||||
"special file": "/emoji/custom/special.png"
|
||||
]
|
||||
|
||||
{:ok, groups: groups}
|
||||
end
|
||||
|
||||
test "config for list of files", %{groups: groups} do
|
||||
group =
|
||||
groups
|
||||
|> Emoji.match_extra("/emoji/custom/first_file.png")
|
||||
|> to_string()
|
||||
|
||||
assert group == "list of files"
|
||||
end
|
||||
|
||||
test "config with wildcard folder", %{groups: groups} do
|
||||
group =
|
||||
groups
|
||||
|> Emoji.match_extra("/emoji/custom/some_folder/file.png")
|
||||
|> to_string()
|
||||
|
||||
assert group == "wildcard folder"
|
||||
end
|
||||
|
||||
test "config with wildcard folder and subfolders", %{groups: groups} do
|
||||
group =
|
||||
groups
|
||||
|> Emoji.match_extra("/emoji/custom/some_folder/another_folder/file.png")
|
||||
|> to_string()
|
||||
|
||||
assert group == "wildcard folder"
|
||||
end
|
||||
|
||||
test "config with wildcard files", %{groups: groups} do
|
||||
group =
|
||||
groups
|
||||
|> Emoji.match_extra("/emoji/custom/folder/some_file.png")
|
||||
|> to_string()
|
||||
|
||||
assert group == "wildcard files"
|
||||
end
|
||||
|
||||
test "config with wildcard files and subfolders", %{groups: groups} do
|
||||
group =
|
||||
groups
|
||||
|> Emoji.match_extra("/emoji/custom/folder/another_folder/some_file.png")
|
||||
|> to_string()
|
||||
|
||||
assert group == "wildcard files"
|
||||
end
|
||||
|
||||
test "config for special file", %{groups: groups} do
|
||||
group =
|
||||
groups
|
||||
|> Emoji.match_extra("/emoji/custom/special.png")
|
||||
|> to_string()
|
||||
|
||||
assert group == "special file"
|
||||
end
|
||||
|
||||
test "no mathing returns nil", %{groups: groups} do
|
||||
group =
|
||||
groups
|
||||
|> Emoji.match_extra("/emoji/some_undefined.png")
|
||||
|
||||
refute group
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -271,7 +271,9 @@ defmodule Pleroma.FormatterTest do
|
|||
test "it returns the emoji used in the text" do
|
||||
text = "I love :moominmamma:"
|
||||
|
||||
assert Formatter.get_emoji(text) == [{"moominmamma", "/finmoji/128px/moominmamma-128.png"}]
|
||||
assert Formatter.get_emoji(text) == [
|
||||
{"moominmamma", "/finmoji/128px/moominmamma-128.png", "Finmoji"}
|
||||
]
|
||||
end
|
||||
|
||||
test "it returns a nice empty result when no emojis are present" do
|
||||
|
|
|
|||
|
|
@ -2342,6 +2342,22 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||
assert acc_two == acc_three
|
||||
end
|
||||
|
||||
describe "custom emoji" do
|
||||
test "with tags", %{conn: conn} do
|
||||
[emoji | _body] =
|
||||
conn
|
||||
|> get("/api/v1/custom_emojis")
|
||||
|> json_response(200)
|
||||
|
||||
assert Map.has_key?(emoji, "shortcode")
|
||||
assert Map.has_key?(emoji, "static_url")
|
||||
assert Map.has_key?(emoji, "tags")
|
||||
assert is_list(emoji["tags"])
|
||||
assert Map.has_key?(emoji, "url")
|
||||
assert Map.has_key?(emoji, "visible_in_picker")
|
||||
end
|
||||
end
|
||||
|
||||
describe "index/2 redirections" do
|
||||
setup %{conn: conn} do
|
||||
session_opts = [
|
||||
|
|
|
|||
|
|
@ -170,6 +170,27 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do
|
|||
end
|
||||
end
|
||||
|
||||
describe "/api/pleroma/emoji" do
|
||||
test "returns json with custom emoji with tags", %{conn: conn} do
|
||||
[emoji | _body] =
|
||||
conn
|
||||
|> get("/api/pleroma/emoji")
|
||||
|> json_response(200)
|
||||
|
||||
[key] = Map.keys(emoji)
|
||||
|
||||
%{
|
||||
^key => %{
|
||||
"image_url" => url,
|
||||
"tags" => tags
|
||||
}
|
||||
} = emoji
|
||||
|
||||
assert is_binary(url)
|
||||
assert is_list(tags)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET /ostatus_subscribe?acct=...." do
|
||||
test "adds status to pleroma instance if the `acct` is a status", %{conn: conn} do
|
||||
conn =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue