From 2f215117493ddff2d615cd37581c48db77aa614f Mon Sep 17 00:00:00 2001 From: Jessica Phoenix Canady Date: Thu, 23 May 2024 16:46:03 -0400 Subject: [PATCH] Refactor Parser tests so the work happens in setup. --- test/lib/blog/parser_test.exs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/test/lib/blog/parser_test.exs b/test/lib/blog/parser_test.exs index c886f4e..1d22aa5 100644 --- a/test/lib/blog/parser_test.exs +++ b/test/lib/blog/parser_test.exs @@ -16,12 +16,25 @@ defmodule JOL.Blog.ParserTest do Body! """ - {:ok, content: content} + {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 - {_attrs, body} = Parser.parse("/fake/filename", post.content) - assert body == "Body!" + 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 attrs from zola-style posts", post do