mirror of
https://github.com/gethomepage/homepage.git
synced 2026-10-01 08:21:18 -07:00
Chore: full react hooks eslint compliance (#7040)
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
// @vitest-environment jsdom
|
||||
|
||||
import { act, render, screen } from "@testing-library/react";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
import useCurrentTime from "./use-current-time";
|
||||
|
||||
function CurrentTime({ refreshInterval }) {
|
||||
return <span>{useCurrentTime(refreshInterval)}</span>;
|
||||
}
|
||||
|
||||
describe("utils/hooks/use-current-time", () => {
|
||||
beforeEach(() => {
|
||||
vi.useFakeTimers();
|
||||
vi.setSystemTime(1_000);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.useRealTimers();
|
||||
});
|
||||
|
||||
it("updates at the requested interval", () => {
|
||||
render(<CurrentTime refreshInterval={5_000} />);
|
||||
expect(screen.getByText("1000")).toBeInTheDocument();
|
||||
|
||||
act(() => {
|
||||
vi.advanceTimersByTime(5_000);
|
||||
});
|
||||
|
||||
expect(screen.getByText("6000")).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user