Merge remote-tracking branch 'origin/develop' into 2018-12-17-update-frontend
[akkoma] / test / formatter_test.exs
index 428227d7826bcb4b0aab89e365ca3d0f280e7c3c..bb318b7d5fe9594f50b84aaf57cfe57060fb316b 100644 (file)
@@ -257,4 +257,23 @@ defmodule Pleroma.FormatterTest do
     text = nil
     assert Formatter.get_emoji(text) == []
   end
+
+  describe "/mentions_escape" do
+    test "it returns text with escaped mention names" do
+      text = """
+      @a_breakin_glass@cybre.space
+      (also, little voice inside my head thinking "maybe this will encourage people
+      pronouncing it properly instead of saying _raKEWdo_ ")
+      """
+
+      escape_text = """
+      @a\\_breakin\\_glass@cybre\\.space
+      (also, little voice inside my head thinking \"maybe this will encourage people
+      pronouncing it properly instead of saying _raKEWdo_ \")
+      """
+
+      mentions = [{"@a_breakin_glass@cybre.space", %{}}]
+      assert Formatter.mentions_escape(text, mentions) == escape_text
+    end
+  end
 end