From 137134dcd09bd4a6c659b917cc377d3815786f8b Mon Sep 17 00:00:00 2001 From: Max Veytsman Date: Wed, 10 Mar 2021 13:51:07 -0500 Subject: [PATCH] Simplify tests --- test/heroicons_test.exs | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/test/heroicons_test.exs b/test/heroicons_test.exs index 6b1c7dc..79fcf6f 100644 --- a/test/heroicons_test.exs +++ b/test/heroicons_test.exs @@ -1,28 +1,31 @@ defmodule HeroiconsTest do use ExUnit.Case, async: true - @icon """ - - - - """ + test "generated function" do + academic_cap = + :code.priv_dir(:heroicons) + |> Path.join("outline/academic-cap.svg") + |> File.read!() - @tag :tmp_dir - test "generated function", %{tmp_dir: tmp_dir} do - Path.join(tmp_dir, "academic_cap.svg") - |> File.write(@icon) - - quote do - defmodule TestIcons do - @icon_dir unquote(Path.absname(tmp_dir)) - @before_compile Heroicons - end - end - |> Code.compile_quoted() - - assert TestIcons.academic_cap() == @icon + assert Heroicons.Outline.academic_cap() == academic_cap assert TestIcons.academic_cap(class: "h-6 w-6 text-gray-500") =~ ~s(class="h-6 w-6 text-gray-500") end + + test "generated docs" do + {:docs_v1, _annotation, _beam_language, _format, _module_doc, + _metadata, docs} = Code.fetch_docs(Heroicons.Outline) + + doc = Enum.find_value(docs, fn {{:function, :academic_cap, 1}, _annotation, _signature, doc, _metadata} -> doc + _ -> nil end) + + assert doc["en"] == """ + ![](assets/outline/academic-cap.svg) {: width=24px} + + ## Examples + iex> academic_cap() + iex> academic_cap(class: "h-6 w-6 text-gray-500") + """ + end end