Fork of Pleroma with site-specific changes and feature branches https://git.pleroma.social/pleroma/pleroma
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

111 lines
2.8KB

  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. defmodule Pleroma.EmojiTest do
  5. use ExUnit.Case, async: true
  6. alias Pleroma.Emoji
  7. describe "get_all/0" do
  8. setup do
  9. emoji_list = Emoji.get_all()
  10. {:ok, emoji_list: emoji_list}
  11. end
  12. test "first emoji", %{emoji_list: emoji_list} do
  13. [emoji | _others] = emoji_list
  14. {code, path, tags} = emoji
  15. assert tuple_size(emoji) == 3
  16. assert is_binary(code)
  17. assert is_binary(path)
  18. assert is_list(tags)
  19. end
  20. test "random emoji", %{emoji_list: emoji_list} do
  21. emoji = Enum.random(emoji_list)
  22. {code, path, tags} = emoji
  23. assert tuple_size(emoji) == 3
  24. assert is_binary(code)
  25. assert is_binary(path)
  26. assert is_list(tags)
  27. end
  28. end
  29. describe "match_extra/2" do
  30. setup do
  31. groups = [
  32. "list of files": ["/emoji/custom/first_file.png", "/emoji/custom/second_file.png"],
  33. "wildcard folder": "/emoji/custom/*/file.png",
  34. "wildcard files": "/emoji/custom/folder/*.png",
  35. "special file": "/emoji/custom/special.png"
  36. ]
  37. {:ok, groups: groups}
  38. end
  39. test "config for list of files", %{groups: groups} do
  40. group =
  41. groups
  42. |> Emoji.match_extra("/emoji/custom/first_file.png")
  43. |> to_string()
  44. assert group == "list of files"
  45. end
  46. test "config with wildcard folder", %{groups: groups} do
  47. group =
  48. groups
  49. |> Emoji.match_extra("/emoji/custom/some_folder/file.png")
  50. |> to_string()
  51. assert group == "wildcard folder"
  52. end
  53. test "config with wildcard folder and subfolders", %{groups: groups} do
  54. group =
  55. groups
  56. |> Emoji.match_extra("/emoji/custom/some_folder/another_folder/file.png")
  57. |> to_string()
  58. assert group == "wildcard folder"
  59. end
  60. test "config with wildcard files", %{groups: groups} do
  61. group =
  62. groups
  63. |> Emoji.match_extra("/emoji/custom/folder/some_file.png")
  64. |> to_string()
  65. assert group == "wildcard files"
  66. end
  67. test "config with wildcard files and subfolders", %{groups: groups} do
  68. group =
  69. groups
  70. |> Emoji.match_extra("/emoji/custom/folder/another_folder/some_file.png")
  71. |> to_string()
  72. assert group == "wildcard files"
  73. end
  74. test "config for special file", %{groups: groups} do
  75. group =
  76. groups
  77. |> Emoji.match_extra("/emoji/custom/special.png")
  78. |> to_string()
  79. assert group == "special file"
  80. end
  81. test "no mathing returns nil", %{groups: groups} do
  82. group =
  83. groups
  84. |> Emoji.match_extra("/emoji/some_undefined.png")
  85. refute group
  86. end
  87. end
  88. end