X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=test%2Fpleroma%2Fweb%2Fcommon_api%2Futils_test.exs;h=c4f506fe35ea9f176321579464b239820f9a796e;hb=e35dced9c899ffa6d64bc94d6993a33c040988ed;hp=c6abbbe84a838d4eeebc03f069d734ea5a4ee998;hpb=c4f4e48e574362d1ec86eaf11a382e81ca97cb35;p=akkoma
diff --git a/test/pleroma/web/common_api/utils_test.exs b/test/pleroma/web/common_api/utils_test.exs
index c6abbbe84..c4f506fe3 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
hello world
another @user__test and @user__test google.com paragraph
) + ~s(hello world
another @user__test and @user__test google.com paragraph
) end end @@ -175,16 +171,56 @@ 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 = "https://github.com/pragdave/earmark/" + {result, [], []} = Utils.format_input(code, "text/markdown") + assert result == ~s[] + 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[] + 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[] + 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[] + end + test "raw HTML" do code = ~s[OwO] {result, [], []} = Utils.format_input(code, "text/markdown") - assert result == "#{code}
" + assert result == ~s[OwO] end test "rulers" do code = ~s[before\n\n-----\n\nafter] {result, [], []} = Utils.format_input(code, "text/markdown") - assert result == "before
after
" + assert result == "before
after
" end test "blockquote" do @@ -204,7 +240,11 @@ 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"
]
+ assert result == ~s[puts "Hello World"
]
+
+ code = ~s[ <div>\n</div>
]
end
test "lists" do
@@ -227,9 +267,9 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do
assert result == ~s[aaaa~
] # strikethrough - code = ~s[aaaa~
aaaa~