Pipeline Ingestion: Note
[akkoma] / test / pleroma / emoji_test.exs
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
5 defmodule Pleroma.EmojiTest do
6 use ExUnit.Case, async: true
7 alias Pleroma.Emoji
8
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?("ね")
13
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?("☂")
18
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
24 # Additionally, we accept regional indicators.
25 assert Emoji.is_unicode_emoji?("🇵")
26 assert Emoji.is_unicode_emoji?("🇴")
27 assert Emoji.is_unicode_emoji?("🇬")
28 end
29 end
30
31 describe "get_all/0" do
32 setup do
33 emoji_list = Emoji.get_all()
34 {:ok, emoji_list: emoji_list}
35 end
36
37 test "first emoji", %{emoji_list: emoji_list} do
38 [emoji | _others] = emoji_list
39 {code, %Emoji{file: path, tags: tags}} = emoji
40
41 assert tuple_size(emoji) == 2
42 assert is_binary(code)
43 assert is_binary(path)
44 assert is_list(tags)
45 end
46
47 test "random emoji", %{emoji_list: emoji_list} do
48 emoji = Enum.random(emoji_list)
49 {code, %Emoji{file: path, tags: tags}} = emoji
50
51 assert tuple_size(emoji) == 2
52 assert is_binary(code)
53 assert is_binary(path)
54 assert is_list(tags)
55 end
56 end
57 end