diff --git a/test/web/common_api/common_api_utils_test.exs b/test/web/common_api/common_api_utils_test.exs index fc89e3116..754bc7255 100644 --- a/test/web/common_api/common_api_utils_test.exs +++ b/test/web/common_api/common_api_utils_test.exs @@ -56,4 +56,54 @@ test "parses emoji from name and bio" do assert expected == Utils.emoji_from_profile(user) end + + describe "format_input/4" do + test "works for bare text/plain" do + text = "hello world!" + expected = "hello world!" + + output = Utils.format_input(text, [], [], "text/plain") + + assert output == expected + + text = "hello world!\n\nsecond paragraph!" + expected = "hello world!

second paragraph!" + + output = Utils.format_input(text, [], [], "text/plain") + + assert output == expected + end + + test "works for bare text/html" do + text = "

hello world!

" + expected = "

hello world!

" + + output = Utils.format_input(text, [], [], "text/html") + + assert output == expected + + text = "

hello world!

\n\n

second paragraph

" + expected = "

hello world!

\n\n

second paragraph

" + + output = Utils.format_input(text, [], [], "text/html") + + assert output == expected + end + + test "works for bare text/markdown" do + text = "**hello world**" + expected = "

hello world

\n" + + output = Utils.format_input(text, [], [], "text/markdown") + + assert output == expected + + text = "**hello world**\n\n*another paragraph*" + expected = "

hello world

\n

another paragraph

\n" + + output = Utils.format_input(text, [], [], "text/markdown") + + assert output == expected + end + end end