prop/test/microwaveprop/weather/map_layers_test.exs
Graham McIntire e3d430f8c4
feat(weather): add duct cutoff band map layer
Show on /weather where the detected duct geometry traps each microwave
band. Overview mode bins cells by their lowest trapped frequency
(Bean & Dutton cutoff); band-picker mode masks cells whose duct doesn't
reach the selected band. Cutoff is pre-computed per cell in both
writers (Elixir derive + Rust derive_row reads best_duct_freq_ghz from
CellValues), persisted to ScalarFile, and shipped to the JS hook via
the existing binary cell pack. Also cleans up six pre-existing
length/1 credo warnings in unrelated test files.
2026-05-15 19:51:24 -05:00

57 lines
1.5 KiB
Elixir

defmodule Microwaveprop.Weather.MapLayersTest do
use ExUnit.Case, async: true
alias Microwaveprop.Weather.MapLayers
describe "all/0" do
test "returns a list of layer maps with required keys" do
layers = MapLayers.all()
assert is_list(layers)
assert match?([_ | _], layers)
Enum.each(layers, fn layer ->
assert Map.has_key?(layer, :id)
assert Map.has_key?(layer, :label)
assert Map.has_key?(layer, :unit)
assert Map.has_key?(layer, :group)
assert Map.has_key?(layer, :desc)
assert is_binary(layer.id)
assert is_binary(layer.label)
end)
end
test "all layer ids are unique" do
ids = Enum.map(MapLayers.all(), & &1.id)
assert length(ids) == ids |> Enum.uniq() |> length()
end
test "includes temperature as the first layer" do
assert hd(MapLayers.all()).id == "temperature"
end
end
describe "default_id/0" do
test "returns temperature" do
assert MapLayers.default_id() == "temperature"
end
end
describe "valid_id?/1" do
test "returns true for known layer ids" do
for layer <- MapLayers.all() do
assert MapLayers.valid_id?(layer.id), "expected #{layer.id} to be valid"
end
end
test "returns false for unknown layer ids" do
refute MapLayers.valid_id?("nonexistent")
end
test "returns false for non-string input" do
refute MapLayers.valid_id?(nil)
refute MapLayers.valid_id?(123)
refute MapLayers.valid_id?(:temperature)
end
end
end