mirror of
https://github.com/gethomepage/homepage.git
synced 2026-09-28 23:11:17 -07:00
Chore: full react hooks eslint compliance (#7040)
This commit is contained in:
@@ -2,8 +2,12 @@ import Block from "components/services/widget/block";
|
||||
import Container from "components/services/widget/container";
|
||||
|
||||
import useWidgetAPI from "utils/proxy/use-widget-api";
|
||||
import withWidgetFields from "utils/widget-fields";
|
||||
|
||||
export default function Component({ service }) {
|
||||
const DEFAULT_FIELDS = ["channels", "hd"];
|
||||
|
||||
export default function Component({ service: configuredService }) {
|
||||
const service = withWidgetFields(configuredService, DEFAULT_FIELDS);
|
||||
const { widget } = service;
|
||||
const { tuner = 0 } = widget;
|
||||
|
||||
@@ -24,15 +28,6 @@ export default function Component({ service }) {
|
||||
);
|
||||
}
|
||||
|
||||
// Provide a default if not set in the config
|
||||
if (!widget.fields) {
|
||||
widget.fields = ["channels", "hd"];
|
||||
}
|
||||
// Limit to a maximum of 4 at a time
|
||||
if (widget.fields.length > 4) {
|
||||
widget.fields = widget.fields.slice(0, 4);
|
||||
}
|
||||
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="hdhomerun.channels" value={channelsData?.length} />
|
||||
|
||||
@@ -58,7 +58,7 @@ describe("widgets/hdhomerun/component", () => {
|
||||
|
||||
const { container } = renderWithProviders(<Component service={service} />, { settings: { hideErrors: false } });
|
||||
|
||||
expect(service.widget.fields).toEqual(["channels", "hd", "tunerCount", "channelNumber"]);
|
||||
expect(service.widget.fields).toEqual(["channels", "hd", "tunerCount", "channelNumber", "signalStrength"]);
|
||||
expect(container.querySelectorAll(".service-block")).toHaveLength(4);
|
||||
expect(screen.getByText("hdhomerun.channels")).toBeInTheDocument();
|
||||
expect(screen.getByText("hdhomerun.hd")).toBeInTheDocument();
|
||||
|
||||
Reference in New Issue
Block a user