mirror of
https://github.com/gethomepage/homepage.git
synced 2026-09-27 06:21:18 -07:00
Chore: full react hooks eslint compliance (#7040)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
// @vitest-environment jsdom
|
||||
|
||||
import { render, waitFor } from "@testing-library/react";
|
||||
import { render, screen, waitFor } from "@testing-library/react";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
const { useWidgetAPI } = vi.hoisted(() => ({
|
||||
@@ -12,6 +12,45 @@ vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI }));
|
||||
import Integration from "./ical";
|
||||
|
||||
describe("widgets/calendar/integrations/ical", () => {
|
||||
it("reports a missing calendar payload without mutating the response", () => {
|
||||
const data = {};
|
||||
useWidgetAPI.mockReturnValue({ data, error: undefined });
|
||||
|
||||
render(
|
||||
<Integration
|
||||
config={{ name: "Work", type: "ical" }}
|
||||
params={{ start: "2099-01-01", end: "2099-01-02" }}
|
||||
setEvents={vi.fn()}
|
||||
hideErrors={false}
|
||||
timezone="utc"
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(screen.getByText(/'Work': calendar\.errorWhenLoadingData/)).toBeInTheDocument();
|
||||
expect(data).toEqual({});
|
||||
});
|
||||
|
||||
it("reports a calendar with no events without mutating the response", () => {
|
||||
const data = {
|
||||
data: ["BEGIN:VCALENDAR", "VERSION:2.0", "PRODID:-//Test//EN", "END:VCALENDAR", ""].join("\n"),
|
||||
};
|
||||
const originalData = structuredClone(data);
|
||||
useWidgetAPI.mockReturnValue({ data, error: undefined });
|
||||
|
||||
render(
|
||||
<Integration
|
||||
config={{ name: "Empty", type: "ical" }}
|
||||
params={{ start: "2099-01-01", end: "2099-01-02" }}
|
||||
setEvents={vi.fn()}
|
||||
hideErrors={false}
|
||||
timezone="utc"
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(screen.getByText(/'Empty': calendar\.noEventsFound/)).toBeInTheDocument();
|
||||
expect(data).toEqual(originalData);
|
||||
});
|
||||
|
||||
it("adds parsed events within the date range", async () => {
|
||||
useWidgetAPI.mockReturnValue({
|
||||
data: {
|
||||
|
||||
Reference in New Issue
Block a user