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 "is_unicode_emoji?/1" do
10 test "tells if a string is an unicode emoji" do
11 refute Emoji.is_unicode_emoji?("X")
12 assert Emoji.is_unicode_emoji?("☂")
13 assert Emoji.is_unicode_emoji?("🥺")
17 describe "get_all/0" do
19 emoji_list = Emoji.get_all()
20 {:ok, emoji_list: emoji_list}
23 test "first emoji", %{emoji_list: emoji_list} do
24 [emoji | _others] = emoji_list
25 {code, path, tags} = emoji
27 assert tuple_size(emoji) == 3
28 assert is_binary(code)
29 assert is_binary(path)
33 test "random emoji", %{emoji_list: emoji_list} do
34 emoji = Enum.random(emoji_list)
35 {code, path, tags} = emoji
37 assert tuple_size(emoji) == 3
38 assert is_binary(code)
39 assert is_binary(path)
44 describe "match_extra/2" do
47 "list of files": ["/emoji/custom/first_file.png", "/emoji/custom/second_file.png"],
48 "wildcard folder": "/emoji/custom/*/file.png",
49 "wildcard files": "/emoji/custom/folder/*.png",
50 "special file": "/emoji/custom/special.png"
56 test "config for list of files", %{groups: groups} do
59 |> Emoji.match_extra("/emoji/custom/first_file.png")
62 assert group == "list of files"
65 test "config with wildcard folder", %{groups: groups} do
68 |> Emoji.match_extra("/emoji/custom/some_folder/file.png")
71 assert group == "wildcard folder"
74 test "config with wildcard folder and subfolders", %{groups: groups} do
77 |> Emoji.match_extra("/emoji/custom/some_folder/another_folder/file.png")
80 assert group == "wildcard folder"
83 test "config with wildcard files", %{groups: groups} do
86 |> Emoji.match_extra("/emoji/custom/folder/some_file.png")
89 assert group == "wildcard files"
92 test "config with wildcard files and subfolders", %{groups: groups} do
95 |> Emoji.match_extra("/emoji/custom/folder/another_folder/some_file.png")
98 assert group == "wildcard files"
101 test "config for special file", %{groups: groups} do
104 |> Emoji.match_extra("/emoji/custom/special.png")
107 assert group == "special file"
110 test "no mathing returns nil", %{groups: groups} do
113 |> Emoji.match_extra("/emoji/some_undefined.png")