1 defmodule Pleroma.EmojiTest do
2 use ExUnit.Case, async: true
5 describe "get_all/0" do
7 emoji_list = Emoji.get_all()
8 {:ok, emoji_list: emoji_list}
11 test "first emoji", %{emoji_list: emoji_list} do
12 [emoji | _others] = emoji_list
13 {code, path, tags} = emoji
15 assert tuple_size(emoji) == 3
16 assert is_binary(code)
17 assert is_binary(path)
21 test "random emoji", %{emoji_list: emoji_list} do
22 emoji = Enum.random(emoji_list)
23 {code, path, tags} = emoji
25 assert tuple_size(emoji) == 3
26 assert is_binary(code)
27 assert is_binary(path)
32 describe "match_extra/2" do
35 "list of files": ["/emoji/custom/first_file.png", "/emoji/custom/second_file.png"],
36 "wildcard folder": "/emoji/custom/*/file.png",
37 "wildcard files": "/emoji/custom/folder/*.png",
38 "special file": "/emoji/custom/special.png"
44 test "config for list of files", %{groups: groups} do
47 |> Emoji.match_extra("/emoji/custom/first_file.png")
50 assert group == "list of files"
53 test "config with wildcard folder", %{groups: groups} do
56 |> Emoji.match_extra("/emoji/custom/some_folder/file.png")
59 assert group == "wildcard folder"
62 test "config with wildcard folder and subfolders", %{groups: groups} do
65 |> Emoji.match_extra("/emoji/custom/some_folder/another_folder/file.png")
68 assert group == "wildcard folder"
71 test "config with wildcard files", %{groups: groups} do
74 |> Emoji.match_extra("/emoji/custom/folder/some_file.png")
77 assert group == "wildcard files"
80 test "config with wildcard files and subfolders", %{groups: groups} do
83 |> Emoji.match_extra("/emoji/custom/folder/another_folder/some_file.png")
86 assert group == "wildcard files"
89 test "config for special file", %{groups: groups} do
92 |> Emoji.match_extra("/emoji/custom/special.png")
95 assert group == "special file"
98 test "no mathing returns nil", %{groups: groups} do
101 |> Emoji.match_extra("/emoji/some_undefined.png")