summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/pleroma/formatter.ex2
-rw-r--r--test/formatter_test.exs10
2 files changed, 12 insertions, 0 deletions
diff --git a/lib/pleroma/formatter.ex b/lib/pleroma/formatter.ex
index cf2944c38..fc2c643da 100644
--- a/lib/pleroma/formatter.ex
+++ b/lib/pleroma/formatter.ex
@@ -157,6 +157,8 @@ defmodule Pleroma.Formatter do
end)
end
+ def get_emoji(nil), do: []
+
def get_emoji(text) do
Enum.filter(@emoji, fn {emoji, _} -> String.contains?(text, ":#{emoji}:") end)
end
diff --git a/test/formatter_test.exs b/test/formatter_test.exs
index 95558089b..4e27efe06 100644
--- a/test/formatter_test.exs
+++ b/test/formatter_test.exs
@@ -199,4 +199,14 @@ defmodule Pleroma.FormatterTest do
assert Formatter.get_emoji(text) == [{"moominmamma", "/finmoji/128px/moominmamma-128.png"}]
end
+
+ test "it returns a nice empty result when no emojis are present" do
+ text = "I love moominamma"
+ assert Formatter.get_emoji(text) == []
+ end
+
+ test "it doesn't die when text is absent" do
+ text = nil
+ assert Formatter.get_emoji(text) == []
+ end
end