add test for markdown

This commit is contained in:
Inhji 2023-07-05 06:49:50 +02:00
parent e87fa125bb
commit 2ac2e1ec01

View file

@ -1,25 +1,31 @@
defmodule ChiyaWeb.MarkdownTest do defmodule ChiyaWeb.MarkdownTest do
use Chiya.DataCase use Chiya.DataCase
alias ChiyaWeb.Markdown alias ChiyaWeb.Markdown
describe "render/1" do describe "render/1" do
test "renders simple markdown" do test "renders simple markdown" do
html = Markdown.render("# Title") html = Markdown.render("# Title")
assert html =~ "id=\"title\"" assert html =~ "id=\"title\""
assert html =~ "Title" assert html =~ "Title"
assert html =~ "</h1>" assert html =~ "</h1>"
end end
test "renders a link to a note" do test "renders a link to a note" do
html = Markdown.render("[[foo]]") html = Markdown.render("[[foo]]")
assert html =~ "/note/foo" assert html =~ "/note/foo"
end end
test "renders a link to a note with custom title" do test "renders a link to a note with custom title" do
html = Markdown.render("[[foo|MyFoo]]") html = Markdown.render("[[foo|MyFoo]]")
assert html =~ "/note/foo" assert html =~ "/note/foo"
assert html =~ "MyFoo" assert html =~ "MyFoo"
end end
end
end test "renders a link to a not existing note with custom class" do
html = Markdown.render("[[foo]]")
assert html =~ "/note/foo"
assert html =~ "class=\"invalid\""
end
end
end