aprs.me/test/aprsme_web/live/components/symbol_renderer_test.exs
Graham McIntire 403300f696
test: broaden unit & property-test coverage (61.8% → 64.7%)
Adds ~800 new tests (incl. 27 StreamData properties) across 22 modules
that previously had little or no coverage. Highlights:

- Pure utility modules (LogSanitizer, PacketFieldWhitelist,
  PacketSanitizer, DeviceParser, CoordinateUtils, BoundsUtils,
  ParamUtils, Convert, WeatherUnits) get thorough unit + property
  coverage including UTF-8 truncation boundaries, antimeridian
  longitude wrap, Haversine symmetry, and unit-conversion inverses.
- JSON view modules (CallsignJSON, ErrorJSON, ChangesetJSON) verified
  for envelope shape and error templating.
- Plugs (HealthCheck, RateLimiter, ApiCSRF) exercised for happy-path
  and halt paths.
- GenServer modules (RegexCache, CleanupScheduler, DeploymentNotifier)
  tested without touching the supervised singleton where possible.
- Drops the orphaned map_live/map_helpers_test.exs whose module name
  collided with the new live/shared/coordinate_utils_test.exs.
2026-04-23 13:32:09 -05:00

90 lines
2.6 KiB
Elixir

defmodule AprsmeWeb.SymbolRendererTest do
use ExUnit.Case, async: true
import Phoenix.LiveViewTest
alias AprsmeWeb.SymbolRenderer
describe "get_sprite_info/2" do
test "delegates to AprsmeWeb.AprsSymbol" do
info = SymbolRenderer.get_sprite_info("/", "_")
assert is_map(info)
assert Map.has_key?(info, :sprite_file)
assert Map.has_key?(info, :background_position)
assert Map.has_key?(info, :background_size)
end
end
describe "render_marker_symbol/4" do
test "returns HTML string for a symbol" do
html = SymbolRenderer.render_marker_symbol("/", ">", "K5ABC", 32)
assert is_binary(html)
assert html =~ "K5ABC"
end
test "works without a callsign" do
html = SymbolRenderer.render_marker_symbol("/", ">")
assert is_binary(html)
end
end
describe "symbol/1 component" do
test "renders a container with the given size" do
html = render_component(&SymbolRenderer.symbol/1, symbol_table: "/", symbol_code: ">", size: 48)
assert html =~ "aprs-symbol-container"
assert html =~ "width: 48px"
assert html =~ "height: 48px"
end
test "includes default size (32px) when size not specified" do
html = render_component(&SymbolRenderer.symbol/1, symbol_table: "/", symbol_code: ">")
assert html =~ "width: 32px"
assert html =~ "height: 32px"
end
test "renders a callsign label when provided" do
html =
render_component(&SymbolRenderer.symbol/1,
symbol_table: "/",
symbol_code: ">",
callsign: "W1AW"
)
assert html =~ "W1AW"
assert html =~ "aprs-callsign-label"
end
test "does not render a callsign label when nil" do
html = render_component(&SymbolRenderer.symbol/1, symbol_table: "/", symbol_code: ">")
refute html =~ "aprs-callsign-label"
end
test "uses explicit title when provided" do
html =
render_component(&SymbolRenderer.symbol/1,
symbol_table: "/",
symbol_code: ">",
title: "Custom title"
)
assert html =~ "Custom title"
end
test "derives title from symbol_table and symbol_code when no explicit title" do
html = render_component(&SymbolRenderer.symbol/1, symbol_table: "/", symbol_code: ">")
# ">" is HTML-escaped to ">"
assert html =~ ~s(title="/>")
end
test "passes additional class through" do
html =
render_component(&SymbolRenderer.symbol/1,
symbol_table: "/",
symbol_code: ">",
class: "extra-class"
)
assert html =~ "extra-class"
end
end
end