Merge branch 'develop' of https://git.pleroma.social/pleroma/pleroma into develop
[akkoma] / test / emoji_test.exs
index 07ac6ff1daada3d8da311f2c512fa59c967c736e..7bdf2b6fae9974e77c931ca284ad3fd44a06048e 100644 (file)
@@ -6,6 +6,14 @@ defmodule Pleroma.EmojiTest do
   use ExUnit.Case, async: true
   alias Pleroma.Emoji
 
+  describe "is_unicode_emoji?/1" do
+    test "tells if a string is an unicode emoji" do
+      refute Emoji.is_unicode_emoji?("X")
+      assert Emoji.is_unicode_emoji?("☂")
+      assert Emoji.is_unicode_emoji?("🥺")
+    end
+  end
+
   describe "get_all/0" do
     setup do
       emoji_list = Emoji.get_all()
@@ -14,9 +22,9 @@ defmodule Pleroma.EmojiTest do
 
     test "first emoji", %{emoji_list: emoji_list} do
       [emoji | _others] = emoji_list
-      {code, path, tags} = emoji
+      {code, %Emoji{file: path, tags: tags}} = emoji
 
-      assert tuple_size(emoji) == 3
+      assert tuple_size(emoji) == 2
       assert is_binary(code)
       assert is_binary(path)
       assert is_list(tags)
@@ -24,87 +32,12 @@ defmodule Pleroma.EmojiTest do
 
     test "random emoji", %{emoji_list: emoji_list} do
       emoji = Enum.random(emoji_list)
-      {code, path, tags} = emoji
+      {code, %Emoji{file: path, tags: tags}} = emoji
 
-      assert tuple_size(emoji) == 3
+      assert tuple_size(emoji) == 2
       assert is_binary(code)
       assert is_binary(path)
       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