| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- /* @vitest-environment node */
- import { describe, it, expect, vi } from "vitest";
- import React from "react";
- import { renderToString } from "react-dom/server";
- /**
- * We mock `next/link` so this unit test does not depend on the Next.js runtime.
- * For a server-render smoke test, a minimal <a href="..."> replacement is enough.
- */
- vi.mock("next/link", async () => {
- const ReactNs = await import("react");
- const React = ReactNs.default ?? ReactNs;
- function LinkMock({ href, children, ...props }) {
- const resolvedHref =
- typeof href === "string"
- ? href
- : href?.pathname
- ? String(href.pathname)
- : "";
- return React.createElement("a", { href: resolvedHref, ...props }, children);
- }
- return { default: LinkMock };
- });
- import AppShell from "./AppShell";
- describe("components/app-shell/AppShell", () => {
- it("renders the shell without crashing and includes key areas", () => {
- const element = React.createElement(
- AppShell,
- null,
- React.createElement("div", null, "Child content")
- );
- const html = renderToString(element);
- // TopNav brand
- expect(html).toContain("RHL Lieferscheine");
- // Sidebar placeholder heading (German)
- expect(html).toContain("Seitenleiste");
- // Rendered children
- expect(html).toContain("Child content");
- });
- });
|