prop/test/microwaveprop/weather/map_layers_test.exs
Graham McIntire b764034e46
test: push coverage to 78.6% — MapLayers 100%, LinkMargin 100%, Elevation 94%
- Weather.MapLayers: unit tests for all/0, default_id/0, valid_id?/1 (25→100%)
- Rover.LinkMargin: link_margin_db ScoresFile round-trip tests (57→100%)
- Rover.Elevation: SRTM tile file read path + void sentinel (44→94%)
- Pskr.Aggregator: pending_count, empty flush tests (65→74%)
- Buildings.MsFootprints: quadkey/bbox pure function tests (51→51%)
- Weather.Grib2.Wgrib2: property tests for parse_lon_val_segment (23→23%)
- test/support/data_case: File.rm_rf -> rm_rf to fix concurrent race
2026-05-07 13:17:40 -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 length(layers) > 0
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 = MapLayers.all() |> Enum.map(& &1.id)
assert length(ids) == Enum.uniq(ids) |> 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