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 # Accept fully-qualified and unqualified 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?("🏳️⚧️")
23 assert Emoji.is_unicode_emoji?("🫵")
25 # Additionally, we accept regional indicators.
26 assert Emoji.is_unicode_emoji?("🇵")
27 assert Emoji.is_unicode_emoji?("🇴")
28 assert Emoji.is_unicode_emoji?("🇬")
32 describe "get_all/0" do
34 emoji_list = Emoji.get_all()
35 {:ok, emoji_list: emoji_list}
38 test "first emoji", %{emoji_list: emoji_list} do
39 [emoji | _others] = emoji_list
40 {code, %Emoji{file: path, tags: tags}} = emoji
42 assert tuple_size(emoji) == 2
43 assert is_binary(code)
44 assert is_binary(path)
48 test "random emoji", %{emoji_list: emoji_list} do
49 emoji = Enum.random(emoji_list)
50 {code, %Emoji{file: path, tags: tags}} = emoji
52 assert tuple_size(emoji) == 2
53 assert is_binary(code)
54 assert is_binary(path)