1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.EmojiTest do
6 use ExUnit.Case, async: true
9 describe "is_unicode_emoji?/1" do
10 test "tells if a string is an unicode emoji" do
11 refute Emoji.is_unicode_emoji?("X")
12 refute Emoji.is_unicode_emoji?("ね")
14 # Only accept fully-qualified (RGI) emoji
15 # See http://www.unicode.org/reports/tr51/
16 refute Emoji.is_unicode_emoji?("❤")
17 refute Emoji.is_unicode_emoji?("☂")
19 assert Emoji.is_unicode_emoji?("🥺")
20 assert Emoji.is_unicode_emoji?("🤰")
21 assert Emoji.is_unicode_emoji?("❤️")
22 assert Emoji.is_unicode_emoji?("🏳️⚧️")
24 # Additionally, we accept regional indicators.
25 assert Emoji.is_unicode_emoji?("🇵")
26 assert Emoji.is_unicode_emoji?("🇴")
27 assert Emoji.is_unicode_emoji?("🇬")
31 describe "get_all/0" do
33 emoji_list = Emoji.get_all()
34 {:ok, emoji_list: emoji_list}
37 test "first emoji", %{emoji_list: emoji_list} do
38 [emoji | _others] = emoji_list
39 {code, %Emoji{file: path, tags: tags}} = emoji
41 assert tuple_size(emoji) == 2
42 assert is_binary(code)
43 assert is_binary(path)
47 test "random emoji", %{emoji_list: emoji_list} do
48 emoji = Enum.random(emoji_list)
49 {code, %Emoji{file: path, tags: tags}} = emoji
51 assert tuple_size(emoji) == 2
52 assert is_binary(code)
53 assert is_binary(path)