logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma

loader_test.exs (2216B)


  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.Emoji.LoaderTest do
  5. use ExUnit.Case, async: true
  6. alias Pleroma.Emoji.Loader
  7. describe "match_extra/2" do
  8. setup do
  9. groups = [
  10. "list of files": ["/emoji/custom/first_file.png", "/emoji/custom/second_file.png"],
  11. "wildcard folder": "/emoji/custom/*/file.png",
  12. "wildcard files": "/emoji/custom/folder/*.png",
  13. "special file": "/emoji/custom/special.png"
  14. ]
  15. {:ok, groups: groups}
  16. end
  17. test "config for list of files", %{groups: groups} do
  18. group =
  19. groups
  20. |> Loader.match_extra("/emoji/custom/first_file.png")
  21. |> to_string()
  22. assert group == "list of files"
  23. end
  24. test "config with wildcard folder", %{groups: groups} do
  25. group =
  26. groups
  27. |> Loader.match_extra("/emoji/custom/some_folder/file.png")
  28. |> to_string()
  29. assert group == "wildcard folder"
  30. end
  31. test "config with wildcard folder and subfolders", %{groups: groups} do
  32. group =
  33. groups
  34. |> Loader.match_extra("/emoji/custom/some_folder/another_folder/file.png")
  35. |> to_string()
  36. assert group == "wildcard folder"
  37. end
  38. test "config with wildcard files", %{groups: groups} do
  39. group =
  40. groups
  41. |> Loader.match_extra("/emoji/custom/folder/some_file.png")
  42. |> to_string()
  43. assert group == "wildcard files"
  44. end
  45. test "config with wildcard files and subfolders", %{groups: groups} do
  46. group =
  47. groups
  48. |> Loader.match_extra("/emoji/custom/folder/another_folder/some_file.png")
  49. |> to_string()
  50. assert group == "wildcard files"
  51. end
  52. test "config for special file", %{groups: groups} do
  53. group =
  54. groups
  55. |> Loader.match_extra("/emoji/custom/special.png")
  56. |> to_string()
  57. assert group == "special file"
  58. end
  59. test "no mathing returns nil", %{groups: groups} do
  60. group =
  61. groups
  62. |> Loader.match_extra("/emoji/some_undefined.png")
  63. refute group
  64. end
  65. end
  66. end