This repository has been archived on 2023-08-07. You can view files and clone it, but cannot push or open issues or pull requests.
temple/test/parser/empty_test.exs

50 lines
1 KiB
Elixir
Raw Normal View History

2021-03-15 04:46:16 +00:00
defmodule Temple.Parser.EmptyTest do
use ExUnit.Case, async: true
alias Temple.Parser.Empty
describe "applicable?/1" do
test "returns true when the node is non-content" do
assert Empty.applicable?(nil)
assert Empty.applicable?([])
end
test "returns fals when the node is a anything other than a string literal" do
for node <- [
"string",
:atom,
%{key: :value},
{:ast?, [], []}
] do
refute Empty.applicable?(node)
end
end
end
describe "run/2" do
test "adds an empty node to the buffer" do
for _ <- [nil, []] do
ast = Empty.run(nil)
assert %Empty{} == ast
2021-03-15 04:46:16 +00:00
end
end
end
2021-04-09 03:04:26 +00:00
2021-04-11 21:27:02 +00:00
describe "Temple.Generator.to_eex/1" do
2021-04-09 03:04:26 +00:00
test "emits eex for non void component" do
raw_ast =
quote do
nil
end
result =
raw_ast
|> Empty.run()
2021-04-11 21:27:02 +00:00
|> Temple.Generator.to_eex()
2021-04-09 03:04:26 +00:00
assert result |> :erlang.iolist_to_binary() == ""
end
end
2021-03-15 04:46:16 +00:00
end