prop/test/microwaveprop/weather/map_layers_test.exs
Graham McIntire cb8445f329
fix: resolve 158/183 credo --strict warnings
- Add 17 missing @spec annotations (layouts, error_json, error_html, skewt_svg)
- Move 12+ nested alias/import/require to module top level
- Add phx-change/id attributes to 11 raw HTML <form> tags
- Remove 4 unused LiveView assigns (:bounds, :data_provider)
- Add 3 missing doctest references (HrrrNativeClient, BulkFetch, Accounts)
- Break 2 long lines (path_compute.ex:382)
- Strengthen weak test assertions (is_binary→byte_size, is_list→!=[])
- Replace Module.concat with Module.safe_concat (2 occurrences)
- Replace length/1 > 0 with list != [] (9 occurrences)
- Remove no-op assert true, fix no-assertion tests

Remaining: 24 socket.assigns introspection warnings (deliberate test
pattern for observable behavior testing), 1 formatter-resistant long
line, 3 app-code usage warnings.
2026-06-12 15:47:15 -05:00

56 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 Enum.all?(layers, &Map.has_key?(&1, :id))
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 byte_size(layer.id) > 0
assert byte_size(layer.label) > 0
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