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/text_test.exs

45 lines
987 B
Elixir
Raw Normal View History

2021-03-15 04:46:16 +00:00
defmodule Temple.Parser.TextTest do
use ExUnit.Case, async: true
alias Temple.Parser.Text
alias Temple.Support.Utils
2021-03-15 04:46:16 +00:00
describe "applicable?/1" do
test "returns true when the node is a string literal" do
assert Text.applicable?("string literal")
end
test "returns fals when the node is a anything other than a string literal" do
for node <- [
:atom,
%{key: :value},
{:ast?, [], []},
[]
] do
refute Text.applicable?(node)
end
end
end
describe "run/2" do
test "adds a text node to the buffer" do
text = "string literal"
ast = Text.run(text)
assert %Text{text: text} == ast
2021-03-15 04:46:16 +00:00
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" do
result =
"string literal"
|> Text.run()
2021-04-11 21:27:02 +00:00
|> Temple.Generator.to_eex()
|> Utils.iolist_to_binary()
2021-04-09 03:04:26 +00:00
assert result == ~s|string literal\n|
2021-04-09 03:04:26 +00:00
end
end
2021-03-15 04:46:16 +00:00
end