Skip to content

Commit

Permalink
Refactor tests for FileProcessor
Browse files Browse the repository at this point in the history
  • Loading branch information
Dalgona committed Feb 1, 2020
1 parent 0c2a993 commit 5d7c2ce
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
9 changes: 5 additions & 4 deletions test/serum/build/file_processor/page_test.exs
Expand Up @@ -4,6 +4,7 @@ defmodule Serum.Build.FileProcessor.PageTest do
import Serum.Build.FileProcessor.Page
import Serum.TestHelper, only: :macros
alias Serum.Error
alias Serum.Page
alias Serum.Project.Loader, as: ProjectLoader
alias Serum.Template
alias Serum.Template.Storage, as: TS
Expand All @@ -18,13 +19,13 @@ defmodule Serum.Build.FileProcessor.PageTest do
{:ok, [proj: proj]}
end

describe "preprocess_pages/2" do
test "preprocesses markdown-EEx files", %{proj: proj} do
describe "preprocess_pages/2 and process_posts/2" do
test "preprocesses markdown files", %{proj: proj} do
file = read("pages/good-md.md")
{:ok, {pages, [compact_page]}} = preprocess_pages([file], proj)
{:ok, [page]} = process_pages(pages, proj)

assert %{
assert %Page{
title: "Test Markdown Page",
label: "test-md",
group: "test",
Expand All @@ -43,7 +44,7 @@ defmodule Serum.Build.FileProcessor.PageTest do
{:ok, {pages, [compact_page]}} = preprocess_pages([file], proj)
{:ok, [page]} = process_pages(pages, proj)

assert %{
assert %Page{
title: "Test HTML-EEx Page",
label: "test-eex",
group: "test",
Expand Down
36 changes: 18 additions & 18 deletions test/serum/build/file_processor/post_test.exs
Expand Up @@ -20,45 +20,45 @@ defmodule Serum.Build.FileProcessor.PostTest do
end

describe "preprocess_posts/2 and process_posts/2" do
test "process HTML-EEx posts", %{proj: proj} do
file = read("posts/good-html.html.eex")
test "process markdown posts", %{proj: proj} do
file = read("posts/good-post.md")
{:ok, {posts, [compact_post]}} = preprocess_posts([file], proj)
{:ok, [post]} = process_posts(posts, proj)

assert %Post{
type: "html",
title: "Test HTML-EEx Post",
type: "md",
title: "Test Post",
date: %DateTime{
year: 2020,
year: 2019,
month: 1,
day: 1,
hour: 0,
minute: 0,
second: 0
hour: 12,
minute: 34,
second: 56
},
tags: [%{name: "serum"}, %{name: "test"}]
tags: [%{name: "tag1"}, %{name: "tag2"}]
} = post

assert_compact(compact_post)
end

test "process markdown posts", %{proj: proj} do
file = read("posts/good-post.md")
test "process HTML-EEx posts", %{proj: proj} do
file = read("posts/good-html.html.eex")
{:ok, {posts, [compact_post]}} = preprocess_posts([file], proj)
{:ok, [post]} = process_posts(posts, proj)

assert %Post{
type: "md",
title: "Test Post",
type: "html",
title: "Test HTML-EEx Post",
date: %DateTime{
year: 2019,
year: 2020,
month: 1,
day: 1,
hour: 12,
minute: 34,
second: 56
hour: 0,
minute: 0,
second: 0
},
tags: [%{name: "tag1"}, %{name: "tag2"}]
tags: [%{name: "serum"}, %{name: "test"}]
} = post

assert_compact(compact_post)
Expand Down

0 comments on commit 5d7c2ce

Please sign in to comment.