X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=test%2Femoji_test.exs;h=2eaa26be695af36aa0d92d4e4207ebb2c68f7d05;hb=1557b99beb3b406572ef2d3baaabed1c9baeca1c;hp=a90213d7dd2b8f4967c68b07d76ede0a7fd3820c;hpb=17d3d05a7196140b62dd791af8d7ced8b0ad9fa1;p=akkoma diff --git a/test/emoji_test.exs b/test/emoji_test.exs index a90213d7d..2eaa26be6 100644 --- a/test/emoji_test.exs +++ b/test/emoji_test.exs @@ -15,7 +15,7 @@ defmodule Pleroma.EmojiTest do assert tuple_size(emoji) == 3 assert is_binary(code) assert is_binary(path) - assert is_binary(tags) + assert is_list(tags) end test "random emoji", %{emoji_list: emoji_list} do @@ -25,7 +25,82 @@ defmodule Pleroma.EmojiTest do assert tuple_size(emoji) == 3 assert is_binary(code) assert is_binary(path) - assert is_binary(tags) + assert is_list(tags) + end + end + + describe "match_extra/2" do + setup do + groups = [ + "list of files": ["/emoji/custom/first_file.png", "/emoji/custom/second_file.png"], + "wildcard folder": "/emoji/custom/*/file.png", + "wildcard files": "/emoji/custom/folder/*.png", + "special file": "/emoji/custom/special.png" + ] + + {:ok, groups: groups} + end + + test "config for list of files", %{groups: groups} do + group = + groups + |> Emoji.match_extra("/emoji/custom/first_file.png") + |> to_string() + + assert group == "list of files" + end + + test "config with wildcard folder", %{groups: groups} do + group = + groups + |> Emoji.match_extra("/emoji/custom/some_folder/file.png") + |> to_string() + + assert group == "wildcard folder" + end + + test "config with wildcard folder and subfolders", %{groups: groups} do + group = + groups + |> Emoji.match_extra("/emoji/custom/some_folder/another_folder/file.png") + |> to_string() + + assert group == "wildcard folder" + end + + test "config with wildcard files", %{groups: groups} do + group = + groups + |> Emoji.match_extra("/emoji/custom/folder/some_file.png") + |> to_string() + + assert group == "wildcard files" + end + + test "config with wildcard files and subfolders", %{groups: groups} do + group = + groups + |> Emoji.match_extra("/emoji/custom/folder/another_folder/some_file.png") + |> to_string() + + assert group == "wildcard files" + end + + test "config for special file", %{groups: groups} do + group = + groups + |> Emoji.match_extra("/emoji/custom/special.png") + |> to_string() + + assert group == "special file" + end + + test "no mathing returns nil", %{groups: groups} do + group = + groups + |> Emoji.match_extra("/emoji/some_undefined.png") + + refute group end end end