Files
MrAlders0n 3e43cfd009 fix: follow up on last week's merges (#55-#101) (#102)
Bugs: clear compare params on tab change, recover channel live messages after a 429,
observer copy link keeps only region params, route table no longer navigates on region
change with nothing selected, map borders memo on data identity, live overview can't
resurrect a failed query, French relative times, no language write on first visit,
0/0 node locations hidden outside the map, path/signal stats use the shared retry rule.

i18n: node/packet/mesh/observer strings that were still hardcoded after #62.

Cleanup: formatUtc, ACTION_BUTTON_CLASS, observer-stats, useWindowedStats, observer-id;
observer pages use StatCard/Card/Field/Segmented/SearchBar/SelectDropdown; one details
chrome on the stats tabs; comment and translations-guide trims; localStorage stub for
Node 26 in the test setup.
2026-09-30 10:19:32 -04:00

32 lines
1.2 KiB
TypeScript

import { describe, it, expect } from "vitest";
import { getStats, observerNoiseFloor } from "../../../src/features/observers/observer-stats";
describe("getStats", () => {
it("returns null when metadata is missing", () => {
expect(getStats(undefined)).toBeNull();
});
it("returns null when stats is not an object", () => {
expect(getStats({ stats: "nope" })).toBeNull();
});
it("returns the stats object when present", () => {
expect(getStats({ stats: { noise_floor: -95, queue_len: 3 } })).toEqual({ noise_floor: -95, queue_len: 3 });
});
});
describe("observerNoiseFloor", () => {
it("returns null when statusMetadata is missing", () => {
expect(observerNoiseFloor({ statusMetadata: undefined })).toBeNull();
});
it("returns null when noise_floor is not a finite number", () => {
expect(observerNoiseFloor({ statusMetadata: { stats: { noise_floor: NaN } } })).toBeNull();
expect(observerNoiseFloor({ statusMetadata: { stats: { noise_floor: "cold" } } })).toBeNull();
});
it("returns the noise floor when it is a finite number", () => {
expect(observerNoiseFloor({ statusMetadata: { stats: { noise_floor: -102.5 } } })).toBe(-102.5);
});
});