Merge branch 'stable' into stable-sync/2.1.1
[akkoma] / test / emoji_test.exs
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
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 assert Emoji.is_unicode_emoji?("☂")
13 assert Emoji.is_unicode_emoji?("🥺")
14 end
15 end
16
17 describe "get_all/0" do
18 setup do
19 emoji_list = Emoji.get_all()
20 {:ok, emoji_list: emoji_list}
21 end
22
23 test "first emoji", %{emoji_list: emoji_list} do
24 [emoji | _others] = emoji_list
25 {code, %Emoji{file: path, tags: tags}} = emoji
26
27 assert tuple_size(emoji) == 2
28 assert is_binary(code)
29 assert is_binary(path)
30 assert is_list(tags)
31 end
32
33 test "random emoji", %{emoji_list: emoji_list} do
34 emoji = Enum.random(emoji_list)
35 {code, %Emoji{file: path, tags: tags}} = emoji
36
37 assert tuple_size(emoji) == 2
38 assert is_binary(code)
39 assert is_binary(path)
40 assert is_list(tags)
41 end
42 end
43 end