1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.EmojiTest do
6 use ExUnit.Case, async: true
9 describe "get_all/0" do
11 emoji_list = Emoji.get_all()
12 {:ok, emoji_list: emoji_list}
15 test "first emoji", %{emoji_list: emoji_list} do
16 [emoji | _others] = emoji_list
17 {code, path, tags} = emoji
19 assert tuple_size(emoji) == 3
20 assert is_binary(code)
21 assert is_binary(path)
25 test "random emoji", %{emoji_list: emoji_list} do
26 emoji = Enum.random(emoji_list)
27 {code, path, tags} = emoji
29 assert tuple_size(emoji) == 3
30 assert is_binary(code)
31 assert is_binary(path)
36 describe "match_extra/2" do
39 "list of files": ["/emoji/custom/first_file.png", "/emoji/custom/second_file.png"],
40 "wildcard folder": "/emoji/custom/*/file.png",
41 "wildcard files": "/emoji/custom/folder/*.png",
42 "special file": "/emoji/custom/special.png"
48 test "config for list of files", %{groups: groups} do
51 |> Emoji.match_extra("/emoji/custom/first_file.png")
54 assert group == "list of files"
57 test "config with wildcard folder", %{groups: groups} do
60 |> Emoji.match_extra("/emoji/custom/some_folder/file.png")
63 assert group == "wildcard folder"
66 test "config with wildcard folder and subfolders", %{groups: groups} do
69 |> Emoji.match_extra("/emoji/custom/some_folder/another_folder/file.png")
72 assert group == "wildcard folder"
75 test "config with wildcard files", %{groups: groups} do
78 |> Emoji.match_extra("/emoji/custom/folder/some_file.png")
81 assert group == "wildcard files"
84 test "config with wildcard files and subfolders", %{groups: groups} do
87 |> Emoji.match_extra("/emoji/custom/folder/another_folder/some_file.png")
90 assert group == "wildcard files"
93 test "config for special file", %{groups: groups} do
96 |> Emoji.match_extra("/emoji/custom/special.png")
99 assert group == "special file"
102 test "no mathing returns nil", %{groups: groups} do
105 |> Emoji.match_extra("/emoji/some_undefined.png")