Files
tribes-plugin-template/test/my_plugin/plugin_test.exs
Steffen Beyer 647d5537ff
Some checks failed
CI / Test (push) Failing after 33s
skeleton
2026-03-25 12:42:19 +01:00

64 lines
1.9 KiB
Elixir

defmodule MyPlugin.PluginTest do
use ExUnit.Case, async: true
describe "register/1" do
setup do
context = %{pubsub: nil, repo: nil}
%{spec: MyPlugin.Plugin.register(context)}
end
test "returns plugin name and version", %{spec: spec} do
assert spec.name == "my_plugin"
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