X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=test%2Fpleroma%2Fweb%2Fcommon_api%2Futils_test.exs;h=b0e567ff0b250acf99905623d62847414cc50758;hb=50a644a2215a144e54a9f9d2a5216bec4e717405;hp=ab6392b1f5fb835d93f94c69edb86cfe62bcb3dc;hpb=f8c93246d69a193ead81248879ba260e98673b3d;p=akkoma diff --git a/test/pleroma/web/common_api/utils_test.exs b/test/pleroma/web/common_api/utils_test.exs index ab6392b1f..b0e567ff0 100644 --- a/test/pleroma/web/common_api/utils_test.exs +++ b/test/pleroma/web/common_api/utils_test.exs @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2020 Pleroma Authors +# Copyright © 2017-2021 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.CommonAPI.UtilsTest do @@ -175,6 +175,54 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do assert result == "

Hello

World!

" end + test "links" do + code = "https://en.wikipedia.org/wiki/Animal_Crossing_(video_game)" + {result, [], []} = Utils.format_input(code, "text/markdown") + assert result == ~s[

#{code}

] + + code = "https://github.com/pragdave/earmark/" + {result, [], []} = Utils.format_input(code, "text/markdown") + assert result == ~s[

#{code}

] + end + + test "link with local mention" do + insert(:user, %{nickname: "lain"}) + + code = "https://example.com/@lain" + {result, [], []} = Utils.format_input(code, "text/markdown") + assert result == ~s[

#{code}

] + end + + test "local mentions" do + mario = insert(:user, %{nickname: "mario"}) + luigi = insert(:user, %{nickname: "luigi"}) + + code = "@mario @luigi yo what's up?" + {result, _, []} = Utils.format_input(code, "text/markdown") + + assert result == + ~s[

@mario @luigi yo what’s up?

] + end + + test "remote mentions" do + mario = insert(:user, %{nickname: "mario@mushroom.world", local: false}) + luigi = insert(:user, %{nickname: "luigi@mushroom.world", local: false}) + + code = "@mario@mushroom.world @luigi@mushroom.world yo what's up?" + {result, _, []} = Utils.format_input(code, "text/markdown") + + assert result == + ~s[

@mario @luigi yo what’s up?

] + end + test "raw HTML" do code = ~s[OwO] {result, [], []} = Utils.format_input(code, "text/markdown") @@ -205,6 +253,10 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do code = ~s[```\nputs "Hello World"\n```] {result, [], []} = Utils.format_input(code, "text/markdown") assert result == ~s[
puts "Hello World"
] + + code = ~s[
\n
] + {result, [], []} = Utils.format_input(code, "text/markdown") + assert result == ~s[
<div>\n</div>
] end test "lists" do