Use Pleroma.Formatter.markdown_to_html/1 in the tests

This commit is contained in:
Mark Felder 2020-12-11 17:28:00 -06:00
parent 6520599b7d
commit f318d8e56d
1 changed files with 14 additions and 14 deletions

View File

@ -6,74 +6,74 @@ defmodule Pleroma.EarmarkRendererTest do
test "Paragraph" do test "Paragraph" do
code = ~s[Hello\n\nWorld!] code = ~s[Hello\n\nWorld!]
result = Earmark.as_html!(code, %Earmark.Options{renderer: Pleroma.EarmarkRenderer}) result = Pleroma.Formatter.markdown_to_html(code)
assert result == "<p>Hello</p><p>World!</p>" assert result == "<p>Hello</p><p>World!</p>"
end end
test "raw HTML" do test "raw HTML" do
code = ~s[<a href="http://example.org/">OwO</a><!-- what's this?-->] code = ~s[<a href="http://example.org/">OwO</a><!-- what's this?-->]
result = Earmark.as_html!(code, %Earmark.Options{renderer: Pleroma.EarmarkRenderer}) result = Pleroma.Formatter.markdown_to_html(code)
assert result == "<p>#{code}</p>" assert result == "<p>#{code}</p>"
end end
test "rulers" do test "rulers" do
code = ~s[before\n\n-----\n\nafter] code = ~s[before\n\n-----\n\nafter]
result = Earmark.as_html!(code, %Earmark.Options{renderer: Pleroma.EarmarkRenderer}) result = Pleroma.Formatter.markdown_to_html(code)
assert result == "<p>before</p><hr /><p>after</p>" assert result == "<p>before</p><hr /><p>after</p>"
end end
test "headings" do test "headings" do
code = ~s[# h1\n## h2\n### h3\n] code = ~s[# h1\n## h2\n### h3\n]
result = Earmark.as_html!(code, %Earmark.Options{renderer: Pleroma.EarmarkRenderer}) result = Pleroma.Formatter.markdown_to_html(code)
assert result == ~s[<h1>h1</h1><h2>h2</h2><h3>h3</h3>] assert result == ~s[<h1>h1</h1><h2>h2</h2><h3>h3</h3>]
end end
test "blockquote" do test "blockquote" do
code = ~s[> whoms't are you quoting?] code = ~s[> whoms't are you quoting?]
result = Earmark.as_html!(code, %Earmark.Options{renderer: Pleroma.EarmarkRenderer}) result = Pleroma.Formatter.markdown_to_html(code)
assert result == "<blockquote><p>whomst are you quoting?</p></blockquote>" assert result == "<blockquote><p>whomst are you quoting?</p></blockquote>"
end end
test "code" do test "code" do
code = ~s[`mix`] code = ~s[`mix`]
result = Earmark.as_html!(code, %Earmark.Options{renderer: Pleroma.EarmarkRenderer}) result = Pleroma.Formatter.markdown_to_html(code)
assert result == ~s[<p><code class="inline">mix</code></p>] assert result == ~s[<p><code class="inline">mix</code></p>]
code = ~s[``mix``] code = ~s[``mix``]
result = Earmark.as_html!(code, %Earmark.Options{renderer: Pleroma.EarmarkRenderer}) result = Pleroma.Formatter.markdown_to_html(code)
assert result == ~s[<p><code class="inline">mix</code></p>] assert result == ~s[<p><code class="inline">mix</code></p>]
code = ~s[```\nputs "Hello World"\n```] code = ~s[```\nputs "Hello World"\n```]
result = Earmark.as_html!(code, %Earmark.Options{renderer: Pleroma.EarmarkRenderer}) result = Pleroma.Formatter.markdown_to_html(code)
assert result == ~s[<pre><code class="">puts &quot;Hello World&quot;</code></pre>] assert result == ~s[<pre><code class="">puts &quot;Hello World&quot;</code></pre>]
end end
test "lists" do test "lists" do
code = ~s[- one\n- two\n- three\n- four] code = ~s[- one\n- two\n- three\n- four]
result = Earmark.as_html!(code, %Earmark.Options{renderer: Pleroma.EarmarkRenderer}) result = Pleroma.Formatter.markdown_to_html(code)
assert result == "<ul><li>one</li><li>two</li><li>three</li><li>four</li></ul>" assert result == "<ul><li>one</li><li>two</li><li>three</li><li>four</li></ul>"
code = ~s[1. one\n2. two\n3. three\n4. four\n] code = ~s[1. one\n2. two\n3. three\n4. four\n]
result = Earmark.as_html!(code, %Earmark.Options{renderer: Pleroma.EarmarkRenderer}) result = Pleroma.Formatter.markdown_to_html(code)
assert result == "<ol><li>one</li><li>two</li><li>three</li><li>four</li></ol>" assert result == "<ol><li>one</li><li>two</li><li>three</li><li>four</li></ol>"
end end
test "delegated renderers" do test "delegated renderers" do
code = ~s[a<br/>b] code = ~s[a<br/>b]
result = Earmark.as_html!(code, %Earmark.Options{renderer: Pleroma.EarmarkRenderer}) result = Pleroma.Formatter.markdown_to_html(code)
assert result == "<p>#{code}</p>" assert result == "<p>#{code}</p>"
code = ~s[*aaaa~*] code = ~s[*aaaa~*]
result = Earmark.as_html!(code, %Earmark.Options{renderer: Pleroma.EarmarkRenderer}) result = Pleroma.Formatter.markdown_to_html(code)
assert result == ~s[<p><em>aaaa~</em></p>] assert result == ~s[<p><em>aaaa~</em></p>]
code = ~s[**aaaa~**] code = ~s[**aaaa~**]
result = Earmark.as_html!(code, %Earmark.Options{renderer: Pleroma.EarmarkRenderer}) result = Pleroma.Formatter.markdown_to_html(code)
assert result == ~s[<p><strong>aaaa~</strong></p>] assert result == ~s[<p><strong>aaaa~</strong></p>]
# strikethrought # strikethrought
code = ~s[<del>aaaa~</del>] code = ~s[<del>aaaa~</del>]
result = Earmark.as_html!(code, %Earmark.Options{renderer: Pleroma.EarmarkRenderer}) result = Pleroma.Formatter.markdown_to_html(code)
assert result == ~s[<p><del>aaaa~</del></p>] assert result == ~s[<p><del>aaaa~</del></p>]
end end
end end