JOL/test/lib/blog/parser_test.exs

50 lines
1.2 KiB
Elixir
Raw Normal View History

defmodule JOL.Blog.ParserTest do
use ExUnit.Case, async: true
alias JOL.Blog.Parser
2024-05-21 16:46:48 +00:00
setup do
content = """
+++
title = "test post"
slug = "test_post"
draft = false
date = 2024-01-02 14:00:00-05:00
[taxonomies]
tags = ["howto", "hardware"]
+++
Body!
"""
{attrs, body} = Parser.parse("/filename/doesnt/matter", content)
{:ok, content: content, attrs: attrs, body: body}
2024-05-21 16:46:48 +00:00
end
2024-05-23 19:26:58 +00:00
test "parses the body from zola-style posts", post do
assert post.body == "Body!"
end
test "parses the title from zola-style posts", post do
assert post.attrs.title == "test post"
end
test "parses the title from zola-style posts", post do
assert post.attrs.title == "test_post"
end
test "parses the tags from zola-style posts", post do
assert post.attrs.tags == ["howto", "hardware"]
end
test "parses the draft status from zola-style posts", post do
assert post.attrs.draft == false
end
2024-05-23 20:48:53 +00:00
test "parses the publish date from zola-style posts", post do
{:ok, known_date, _} = DateTime.from_iso8601("2024-01-02 14:00:00-05:00")
assert Date.compare(known_date, post.attrs.date) == :eq
end
end