31 lines
1.1 KiB
TypeScript
31 lines
1.1 KiB
TypeScript
// @vitest-environment jsdom
|
|
import { render, screen } from "@testing-library/react";
|
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
|
|
vi.mock("react-router", () => ({
|
|
useNavigation: () => ({ state: "loading", location: { pathname: "/acme/projects" } }),
|
|
}));
|
|
|
|
vi.mock("spin-delay", () => ({ useSpinDelay: () => true }));
|
|
vi.mock("@headlessui/react", () => ({ Transition: ({ children }: { children: React.ReactNode }) => children }));
|
|
vi.mock("react-i18next", () => ({ useTranslation: () => ({ t: (key: string) => key }) }));
|
|
vi.mock("~/ui/components/Loader", () => ({ Loader: () => <span data-testid="loader" /> }));
|
|
|
|
import FloatingLoader from "./FloatingLoader";
|
|
|
|
afterEach(() => {
|
|
vi.restoreAllMocks();
|
|
});
|
|
|
|
describe("FloatingLoader", () => {
|
|
it("renders navigation progress without starting an unused update timer", () => {
|
|
const setIntervalSpy = vi.spyOn(globalThis, "setInterval");
|
|
|
|
render(<FloatingLoader />);
|
|
|
|
expect(screen.getByTestId("loader")).toBeTruthy();
|
|
expect(document.body.textContent).toContain("/acme/projects");
|
|
expect(setIntervalSpy).not.toHaveBeenCalled();
|
|
});
|
|
});
|