Compare commits

..
1 Commits
Author SHA1 Message Date
Crowdin Bot 598acf69ba New Crowdin translations by GitHub Action
Lint / Linting Checks (push) Has been cancelled
Tests / vitest (1) (push) Has been cancelled
Tests / vitest (2) (push) Has been cancelled
Tests / vitest (3) (push) Has been cancelled
Tests / vitest (4) (push) Has been cancelled
2026-09-13 00:58:11 +00:00
2 changed files with 7 additions and 16 deletions
+7 -5
View File
@@ -41,15 +41,17 @@ export default function Component({ service }) {
status = t("peanut.low_battery");
break;
default:
status = typeof upsStatus === "string" && upsStatus ? upsStatus : "-";
status = upsStatus;
}
const percent = (value) => (value === undefined || value === null ? "-" : t("common.percent", { value }));
return (
<Container service={service}>
<Block label="peanut.battery_charge" value={percent(batteryCharge)} highlightValue={batteryCharge} />
<Block label="peanut.ups_load" value={percent(upsLoad)} highlightValue={upsLoad} />
<Block
label="peanut.battery_charge"
value={t("common.percent", { value: batteryCharge })}
highlightValue={batteryCharge}
/>
<Block label="peanut.ups_load" value={t("common.percent", { value: upsLoad })} highlightValue={upsLoad} />
<Block label="peanut.ups_status" value={status} />
</Container>
);
-11
View File
@@ -51,15 +51,4 @@ describe("widgets/peanut/component", () => {
expect(screen.getByText("peanut.online")).toBeInTheDocument();
expect(data).toEqual({ "battery.charge": 55, "ups.load": 12, "ups.status": "OL" });
});
it("renders dashes when readings are missing", () => {
useWidgetAPI.mockReturnValue({
data: { "device.model": "OR500LCDRM1Ua", "ups.status": 0 },
error: undefined,
});
renderWithProviders(<Component service={{ widget: { type: "peanut" } }} />, { settings: { hideErrors: false } });
expect(screen.getAllByText("-")).toHaveLength(3);
});
});