2021-03-03 17:35:03 -05:00
|
|
|
defmodule HeroiconsTest do
|
|
|
|
use ExUnit.Case, async: true
|
2021-03-06 16:53:46 -05:00
|
|
|
|
2021-03-10 13:51:07 -05:00
|
|
|
test "generated function" do
|
|
|
|
academic_cap =
|
|
|
|
:code.priv_dir(:heroicons)
|
|
|
|
|> Path.join("outline/academic-cap.svg")
|
|
|
|
|> File.read!()
|
2021-03-06 16:53:46 -05:00
|
|
|
|
2021-03-10 14:30:12 -05:00
|
|
|
assert Heroicons.Outline.academic_cap()
|
|
|
|
|> Phoenix.HTML.safe_to_string() ==
|
|
|
|
academic_cap
|
2021-03-06 16:53:46 -05:00
|
|
|
|
2021-03-10 14:30:12 -05:00
|
|
|
assert Heroicons.Outline.academic_cap(class: "h-6 w-6 text-gray-500")
|
|
|
|
|> Phoenix.HTML.safe_to_string() =~
|
2021-03-06 16:53:46 -05:00
|
|
|
~s(class="h-6 w-6 text-gray-500")
|
2021-03-10 14:30:12 -05:00
|
|
|
|
|
|
|
assert Heroicons.Outline.academic_cap(class: "<> \" ")
|
|
|
|
|> Phoenix.HTML.safe_to_string() =~
|
2021-03-19 12:30:56 -04:00
|
|
|
~s(class="<> " ")
|
|
|
|
|
|
|
|
assert Heroicons.Outline.academic_cap(foo: "bar")
|
|
|
|
|> Phoenix.HTML.safe_to_string() =~
|
|
|
|
~s(foo="bar")
|
|
|
|
|
|
|
|
assert Heroicons.Outline.academic_cap(multiword_key: "foo")
|
|
|
|
|> Phoenix.HTML.safe_to_string() =~
|
|
|
|
~s(multiword-key="foo")
|
2021-03-06 16:53:46 -05:00
|
|
|
end
|
2021-03-10 13:51:07 -05:00
|
|
|
|
|
|
|
test "generated docs" do
|
2021-03-10 14:30:12 -05:00
|
|
|
{:docs_v1, _annotation, _beam_language, _format, _module_doc, _metadata, docs} =
|
|
|
|
Code.fetch_docs(Heroicons.Outline)
|
2021-03-10 13:51:07 -05:00
|
|
|
|
2021-03-10 14:30:12 -05:00
|
|
|
doc =
|
|
|
|
Enum.find_value(docs, fn
|
|
|
|
{{:function, :academic_cap, 1}, _annotation, _signature, doc, _metadata} -> doc
|
|
|
|
_ -> nil
|
|
|
|
end)
|
2021-03-10 13:51:07 -05:00
|
|
|
|
|
|
|
assert doc["en"] == """
|
2021-03-10 14:30:12 -05:00
|
|
|
 {: width=24px}
|
2021-03-10 13:51:07 -05:00
|
|
|
|
2021-03-10 14:30:12 -05:00
|
|
|
## Examples
|
|
|
|
iex> academic_cap()
|
|
|
|
iex> academic_cap(class: "h-6 w-6 text-gray-500")
|
|
|
|
"""
|
2021-03-10 13:51:07 -05:00
|
|
|
end
|
2021-03-03 17:35:03 -05:00
|
|
|
end
|