defmodule Aether.PluginTest do use ExUnit.Case, async: true describe "register/1" do setup do context = %{pubsub: nil, repo: nil} %{spec: Aether.Plugin.register(context)} end test "returns plugin name and version", %{spec: spec} do assert spec.name == "aether" assert is_binary(spec.version) end test "provides is a list of capability strings", %{spec: spec} do assert is_list(spec.provides) for cap <- spec.provides do assert is_binary(cap), "capability must be a string, got: #{inspect(cap)}" end end test "requires is a list of capability strings", %{spec: spec} do assert is_list(spec.requires) for cap <- spec.requires do assert is_binary(cap), "capability must be a string, got: #{inspect(cap)}" end end test "nav items have required fields", %{spec: spec} do assert is_list(spec.nav_items) for item <- spec.nav_items do assert is_binary(item.label), "nav item must have a label" assert is_binary(item.path), "nav item must have a path" assert is_integer(item.order), "nav item must have an integer order" end end test "pages reference existing modules", %{spec: spec} do assert is_list(spec.pages) for page <- spec.pages do assert is_binary(page.path), "page must have a path" assert is_atom(page.live_view), "page must have a live_view module" assert Code.ensure_loaded?(page.live_view), "module #{page.live_view} must be loadable" end end test "children are valid child specs", %{spec: spec} do assert is_list(spec.children) end test "asset lists are string lists", %{spec: spec} do assert is_list(spec.global_js) assert is_list(spec.global_css) for js <- spec.global_js, do: assert(is_binary(js)) for css <- spec.global_css, do: assert(is_binary(css)) end end end