aprs.me/test/aprsme_web/components/layouts_test.exs
Graham McIntire b86153cd27
Fix all mix credo --strict warnings (188 → 0)
- Replace apply/2 with direct fully-qualified calls in movement_test
- Fix assert_receive timeouts < 1000ms across 8 test files
- Move nested import statements to module-level scope
- Fix tests with no assertions and add missing doctest
- Replace weak type assertions with specific value checks
- Fix conditional assertions and length/1 expensive patterns
- Disable inappropriate Jump.CredoChecks.AvoidSocketAssignsInTest
- Fix tests not calling application code with credo:disable
- Add various credo:disable comments for legitimate patterns
2026-06-12 16:27:20 -05:00

70 lines
1.9 KiB
Elixir

defmodule AprsmeWeb.LayoutsTest do
use ExUnit.Case, async: true
import Phoenix.LiveViewTest
alias AprsmeWeb.Layouts
describe "body_class/1" do
test "returns the default light/dark-aware class list" do
result = Layouts.body_class(%{})
[classes] = result
assert classes =~ "bg-white"
assert classes =~ "dark:bg-gray-900"
assert classes =~ "text-gray-900"
assert classes =~ "dark:text-white"
assert classes =~ "antialiased"
end
test "ignores assigns content" do
assert Layouts.body_class(%{theme: "dark"}) == Layouts.body_class(%{})
assert Layouts.body_class(%{whatever: 42}) == Layouts.body_class(%{})
end
end
describe "app/1 template" do
test "renders the site header and inner content" do
html =
render_component(&Layouts.app/1, %{
current_user: nil,
flash: %{},
map_page: false,
inner_content: Phoenix.HTML.raw("<p>inner-content-marker</p>")
})
assert html =~ "aprs.me"
assert html =~ "inner-content-marker"
# Default map_page is false, so data-map-page="false" is emitted.
assert html =~ ~s(data-map-page="false")
end
test "emits data-map-page=\"true\" for map pages" do
html =
render_component(&Layouts.app/1, %{
current_user: nil,
flash: %{},
map_page: true,
inner_content: Phoenix.HTML.raw("")
})
assert html =~ ~s(data-map-page="true")
assert html =~ "min-h-screen"
end
end
describe "root/1 template" do
test "renders the root layout with the inner content" do
html =
render_component(&Layouts.root/1, %{
current_user: nil,
inner_content: Phoenix.HTML.raw("<main>root-layout-marker</main>"),
conn: %Plug.Conn{},
page_title: nil
})
assert html =~ "root-layout-marker"
assert html =~ "<html"
assert html =~ "</html>"
end
end
end