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/utils_test.exs
Mitchell Hanberg 9d05f74cdf
Properly emit boolean attributes (#139)
* Update some docs

* Properly emit boolean attributes.

* Account for quoted literals when compiling attributes

* Update changelog
2021-06-26 21:47:21 -04:00

27 lines
654 B
Elixir

defmodule Temple.Parser.UtilsTest do
use ExUnit.Case, async: true
alias Temple.Parser.Utils
describe "runtime_attrs/1" do
test "compiles keyword lists and maps into html attributes" do
attrs_map = %{
class: "text-red",
id: "form1",
disabled: false,
inner_block: %{}
}
attrs_kw = [
class: "text-red",
id: "form1",
disabled: true,
inner_block: %{}
]
assert {:safe, ~s| class="text-red" id="form1"|} == Utils.runtime_attrs(attrs_map)
assert {:safe, ~s| class="text-red" id="form1" disabled|} == Utils.runtime_attrs(attrs_kw)
end
end
end