1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Emoji.LoaderTest do
6 use ExUnit.Case, async: true
7 alias Pleroma.Emoji.Loader
9 describe "match_extra/2" do
12 "list of files": ["/emoji/custom/first_file.png", "/emoji/custom/second_file.png"],
13 "wildcard folder": "/emoji/custom/*/file.png",
14 "wildcard files": "/emoji/custom/folder/*.png",
15 "special file": "/emoji/custom/special.png"
21 test "config for list of files", %{groups: groups} do
24 |> Loader.match_extra("/emoji/custom/first_file.png")
27 assert group == "list of files"
30 test "config with wildcard folder", %{groups: groups} do
33 |> Loader.match_extra("/emoji/custom/some_folder/file.png")
36 assert group == "wildcard folder"
39 test "config with wildcard folder and subfolders", %{groups: groups} do
42 |> Loader.match_extra("/emoji/custom/some_folder/another_folder/file.png")
45 assert group == "wildcard folder"
48 test "config with wildcard files", %{groups: groups} do
51 |> Loader.match_extra("/emoji/custom/folder/some_file.png")
54 assert group == "wildcard files"
57 test "config with wildcard files and subfolders", %{groups: groups} do
60 |> Loader.match_extra("/emoji/custom/folder/another_folder/some_file.png")
63 assert group == "wildcard files"
66 test "config for special file", %{groups: groups} do
69 |> Loader.match_extra("/emoji/custom/special.png")
72 assert group == "special file"
75 test "no mathing returns nil", %{groups: groups} do
78 |> Loader.match_extra("/emoji/some_undefined.png")