add signal strength indicator dot to all systems table

This commit is contained in:
henrygd
2026-09-25 19:23:52 -04:00
parent 46fa7c581e
commit fe83f5b831
3 changed files with 36 additions and 8 deletions

View File

@@ -1,5 +1,6 @@
import { expect, test } from "bun:test"
import { connectedWiFi, strongestWiFiSignal, wifiColor } from "./wifi"
import { MeterState } from "@/lib/enums"
import { connectedWiFi, strongestWiFiSignal, wifiColor, wifiSignalState } from "./wifi"
import type { SystemInfo } from "@/types"
const system = (wf?: SystemInfo["wf"], status: "up" | "down" = "up") => ({ status, info: { wf } as SystemInfo })
@@ -26,3 +27,11 @@ test("strongestWiFiSignal returns the strongest current native RSSI", () => {
expect(strongestWiFiSignal(system({ wlan0: {} }))).toBeUndefined()
expect(strongestWiFiSignal(system({ wlan0: { r: -48 } }, "down"))).toBeUndefined()
})
test("wifiSignalState thresholds", () => {
expect(wifiSignalState(-40)).toBe(MeterState.Good)
expect(wifiSignalState(-65)).toBe(MeterState.Good)
expect(wifiSignalState(-66)).toBe(MeterState.Warn)
expect(wifiSignalState(-75)).toBe(MeterState.Warn)
expect(wifiSignalState(-76)).toBe(MeterState.Crit)
})