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.

58 lines
1.6KB

  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2021 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 "is_unicode_emoji?/1" do
  8. test "tells if a string is an unicode emoji" do
  9. refute Emoji.is_unicode_emoji?("X")
  10. refute Emoji.is_unicode_emoji?("ね")
  11. # Only accept fully-qualified (RGI) emoji
  12. # See http://www.unicode.org/reports/tr51/
  13. refute Emoji.is_unicode_emoji?("❤")
  14. refute Emoji.is_unicode_emoji?("☂")
  15. assert Emoji.is_unicode_emoji?("🥺")
  16. assert Emoji.is_unicode_emoji?("🤰")
  17. assert Emoji.is_unicode_emoji?("❤️")
  18. assert Emoji.is_unicode_emoji?("🏳️‍⚧️")
  19. # Additionally, we accept regional indicators.
  20. assert Emoji.is_unicode_emoji?("🇵")
  21. assert Emoji.is_unicode_emoji?("🇴")
  22. assert Emoji.is_unicode_emoji?("🇬")
  23. end
  24. end
  25. describe "get_all/0" do
  26. setup do
  27. emoji_list = Emoji.get_all()
  28. {:ok, emoji_list: emoji_list}
  29. end
  30. test "first emoji", %{emoji_list: emoji_list} do
  31. [emoji | _others] = emoji_list
  32. {code, %Emoji{file: path, tags: tags}} = emoji
  33. assert tuple_size(emoji) == 2
  34. assert is_binary(code)
  35. assert is_binary(path)
  36. assert is_list(tags)
  37. end
  38. test "random emoji", %{emoji_list: emoji_list} do
  39. emoji = Enum.random(emoji_list)
  40. {code, %Emoji{file: path, tags: tags}} = emoji
  41. assert tuple_size(emoji) == 2
  42. assert is_binary(code)
  43. assert is_binary(path)
  44. assert is_list(tags)
  45. end
  46. end
  47. end