diff --git a/lib/microwaveprop_web/live/contact_live/show.ex b/lib/microwaveprop_web/live/contact_live/show.ex index c545f440..9a642938 100644 --- a/lib/microwaveprop_web/live/contact_live/show.ex +++ b/lib/microwaveprop_web/live/contact_live/show.ex @@ -1473,7 +1473,7 @@ defmodule MicrowavepropWeb.ContactLive.Show do defp format_band(band) do mhz = Decimal.to_float(band) - if mhz < 1000 do + if mhz < 10_000 do if mhz == Float.round(mhz, 0) do "#{trunc(mhz)} MHz" else diff --git a/test/microwaveprop_web/live/contact_live_test.exs b/test/microwaveprop_web/live/contact_live_test.exs index ddb561dc..238bf0ad 100644 --- a/test/microwaveprop_web/live/contact_live_test.exs +++ b/test/microwaveprop_web/live/contact_live_test.exs @@ -150,14 +150,13 @@ defmodule MicrowavepropWeb.ContactLiveTest do assert render(lv) =~ contact.station1 end - # Band display on the detail page: below 1 GHz renders in MHz, at/above - # 1 GHz renders in GHz. Amateur band labels match the unit operators use - # in QSO logs — you work 432 MHz, you work 10 GHz. - test "renders sub-GHz bands in MHz", %{conn: conn} do + # Band display on the detail page: below 10 GHz renders in MHz, at/above + # 10 GHz renders in GHz. Amateur microwave convention — 2304 is "2304", + # 3456 is "3456", 5760 is "5760", not "2.3 GHz" etc. + test "renders sub-10-GHz bands in MHz", %{conn: conn} do contact = create_contact(%{band: Decimal.new("432")}) {:ok, _lv, html} = live(conn, ~p"/contacts/#{contact.id}") assert html =~ "432 MHz" - refute html =~ "0.4 GHz" end test "renders 50 MHz in MHz", %{conn: conn} do @@ -166,16 +165,30 @@ defmodule MicrowavepropWeb.ContactLiveTest do assert html =~ "50 MHz" end - test "renders GHz bands in GHz", %{conn: conn} do + test "renders 1296 MHz in MHz", %{conn: conn} do + contact = create_contact(%{band: Decimal.new("1296")}) + {:ok, _lv, html} = live(conn, ~p"/contacts/#{contact.id}") + assert html =~ "1296 MHz" + refute html =~ "1.3 GHz" + end + + test "renders 2304 MHz in MHz", %{conn: conn} do + contact = create_contact(%{band: Decimal.new("2304")}) + {:ok, _lv, html} = live(conn, ~p"/contacts/#{contact.id}") + assert html =~ "2304 MHz" + refute html =~ "2.3 GHz" + end + + test "renders 10 GHz in GHz (threshold)", %{conn: conn} do contact = create_contact(%{band: Decimal.new("10000")}) {:ok, _lv, html} = live(conn, ~p"/contacts/#{contact.id}") assert html =~ "10 GHz" end - test "renders 1296 MHz as 1.3 GHz (above the 1 GHz threshold)", %{conn: conn} do - contact = create_contact(%{band: Decimal.new("1296")}) + test "renders 24 GHz in GHz", %{conn: conn} do + contact = create_contact(%{band: Decimal.new("24000")}) {:ok, _lv, html} = live(conn, ~p"/contacts/#{contact.id}") - assert html =~ "1.3 GHz" + assert html =~ "24 GHz" end test "raises for bad UUID", %{conn: conn} do