diff options
author | Wim Vanderbauwhede <wim.vanderbauwhede@mail.be> | 2019-02-14 16:41:40 +0000 |
---|---|---|
committer | Wim Vanderbauwhede <wim.vanderbauwhede@mail.be> | 2019-02-14 16:41:40 +0000 |
commit | 04b1c135543965860029557fc216eb38fd63b6c7 (patch) | |
tree | c1fb60376eeb35539704c23d282af7777895d4ea /test/web/common_api/common_api_utils_test.exs | |
parent | bf5b1c7f06c9f8882c40cf2385439bee3b74522c (diff) | |
parent | 1d17082ab2523eb75ee0ca4a49e45da0d0edabd7 (diff) | |
download | pleroma-04b1c135543965860029557fc216eb38fd63b6c7.tar.gz |
Merge remote-tracking branch 'upstream/develop' into patch-image-description
Diffstat (limited to 'test/web/common_api/common_api_utils_test.exs')
-rw-r--r-- | test/web/common_api/common_api_utils_test.exs | 52 |
1 files changed, 51 insertions, 1 deletions
diff --git a/test/web/common_api/common_api_utils_test.exs b/test/web/common_api/common_api_utils_test.exs index fc89e3116..faed6b685 100644 --- a/test/web/common_api/common_api_utils_test.exs +++ b/test/web/common_api/common_api_utils_test.exs @@ -5,7 +5,7 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do alias Pleroma.Web.CommonAPI.Utils alias Pleroma.Web.Endpoint - alias Pleroma.Builders.{UserBuilder} + alias Pleroma.Builders.UserBuilder use Pleroma.DataCase test "it adds attachment links to a given text and attachment set" do @@ -56,4 +56,54 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest 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!<br><br>second paragraph!" + + output = Utils.format_input(text, [], [], "text/plain") + + assert output == expected + end + + test "works for bare text/html" do + text = "<p>hello world!</p>" + expected = "<p>hello world!</p>" + + output = Utils.format_input(text, [], [], "text/html") + + assert output == expected + + text = "<p>hello world!</p>\n\n<p>second paragraph</p>" + expected = "<p>hello world!</p>\n\n<p>second paragraph</p>" + + output = Utils.format_input(text, [], [], "text/html") + + assert output == expected + end + + test "works for bare text/markdown" do + text = "**hello world**" + expected = "<p><strong>hello world</strong></p>\n" + + output = Utils.format_input(text, [], [], "text/markdown") + + assert output == expected + + text = "**hello world**\n\n*another paragraph*" + expected = "<p><strong>hello world</strong></p>\n<p><em>another paragraph</em></p>\n" + + output = Utils.format_input(text, [], [], "text/markdown") + + assert output == expected + end + end end |