- 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
88 lines
2.6 KiB
Elixir
88 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 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 html =~ "K5ABC"
|
|
end
|
|
|
|
test "works without a callsign" do
|
|
html = SymbolRenderer.render_marker_symbol("/", ">")
|
|
assert String.length(html) > 0
|
|
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
|