defmodule JOL.Blog.ParserTest do use ExUnit.Case, async: true alias JOL.Blog.Parser setup do content = """ +++ title = "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} end 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 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 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