Chore: homepage tests (#6278)

This commit is contained in:
shamoon
2026-02-04 19:58:39 -08:00
committed by GitHub
parent 7d019185a3
commit 872a3600aa
558 changed files with 32606 additions and 84 deletions

View File

@@ -0,0 +1,38 @@
// @vitest-environment jsdom
import { render, screen } from "@testing-library/react";
import { describe, expect, it, vi } from "vitest";
import ErrorBoundary from "./errorboundry";
describe("components/errorboundry", () => {
it("renders children when no error is thrown", () => {
render(
<ErrorBoundary>
<div>ok</div>
</ErrorBoundary>,
);
expect(screen.getByText("ok")).toBeInTheDocument();
});
it("renders a fallback UI when a child throws", () => {
const consoleSpy = vi.spyOn(console, "error").mockImplementation(() => {});
try {
const Boom = () => {
throw new Error("boom");
};
render(
<ErrorBoundary>
<Boom />
</ErrorBoundary>,
);
expect(screen.getByText("Something went wrong.")).toBeInTheDocument();
expect(screen.getByText("Error: boom")).toBeInTheDocument();
} finally {
consoleSpy.mockRestore();
}
});
});