Exclude reblogs from `GET /api/pleroma/admin/statuses` by default
[akkoma] / test / emoji / loader_test.exs
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Emoji.LoaderTest do
6 use ExUnit.Case, async: true
7 alias Pleroma.Emoji.Loader
8
9 describe "match_extra/2" do
10 setup do
11 groups = [
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"
16 ]
17
18 {:ok, groups: groups}
19 end
20
21 test "config for list of files", %{groups: groups} do
22 group =
23 groups
24 |> Loader.match_extra("/emoji/custom/first_file.png")
25 |> to_string()
26
27 assert group == "list of files"
28 end
29
30 test "config with wildcard folder", %{groups: groups} do
31 group =
32 groups
33 |> Loader.match_extra("/emoji/custom/some_folder/file.png")
34 |> to_string()
35
36 assert group == "wildcard folder"
37 end
38
39 test "config with wildcard folder and subfolders", %{groups: groups} do
40 group =
41 groups
42 |> Loader.match_extra("/emoji/custom/some_folder/another_folder/file.png")
43 |> to_string()
44
45 assert group == "wildcard folder"
46 end
47
48 test "config with wildcard files", %{groups: groups} do
49 group =
50 groups
51 |> Loader.match_extra("/emoji/custom/folder/some_file.png")
52 |> to_string()
53
54 assert group == "wildcard files"
55 end
56
57 test "config with wildcard files and subfolders", %{groups: groups} do
58 group =
59 groups
60 |> Loader.match_extra("/emoji/custom/folder/another_folder/some_file.png")
61 |> to_string()
62
63 assert group == "wildcard files"
64 end
65
66 test "config for special file", %{groups: groups} do
67 group =
68 groups
69 |> Loader.match_extra("/emoji/custom/special.png")
70 |> to_string()
71
72 assert group == "special file"
73 end
74
75 test "no mathing returns nil", %{groups: groups} do
76 group =
77 groups
78 |> Loader.match_extra("/emoji/some_undefined.png")
79
80 refute group
81 end
82 end
83 end