feat(contact-detail): use 10 GHz threshold for MHz/GHz band display
Anything below 10 GHz now renders in MHz so 2304/3456/5760 etc. match amateur microwave convention. 10 GHz and above still render in GHz.
This commit is contained in:
parent
59af48e123
commit
2a57074a47
2 changed files with 23 additions and 10 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue