mirror of
https://github.com/gethomepage/homepage.git
synced 2026-10-03 09:21:18 -07:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
598acf69ba |
@@ -41,15 +41,17 @@ export default function Component({ service }) {
|
|||||||
status = t("peanut.low_battery");
|
status = t("peanut.low_battery");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
status = typeof upsStatus === "string" && upsStatus ? upsStatus : "-";
|
status = upsStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
const percent = (value) => (value === undefined || value === null ? "-" : t("common.percent", { value }));
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container service={service}>
|
<Container service={service}>
|
||||||
<Block label="peanut.battery_charge" value={percent(batteryCharge)} highlightValue={batteryCharge} />
|
<Block
|
||||||
<Block label="peanut.ups_load" value={percent(upsLoad)} highlightValue={upsLoad} />
|
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} />
|
<Block label="peanut.ups_status" value={status} />
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -51,15 +51,4 @@ describe("widgets/peanut/component", () => {
|
|||||||
expect(screen.getByText("peanut.online")).toBeInTheDocument();
|
expect(screen.getByText("peanut.online")).toBeInTheDocument();
|
||||||
expect(data).toEqual({ "battery.charge": 55, "ups.load": 12, "ups.status": "OL" });
|
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);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user