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