Files
Moh e2e06be86e test: add comprehensive automated test coverage
- Vitest multi-project setup (unit / integration / component)
- Real-Postgres integration harness via in-process PGlite (TEST_DATABASE_URL
  override), migrations applied per worker; production code untouched
- Unit: routing, locale, validation/Zod schemas, metadata, mail, site-theme,
  marquee, media, portfolio helpers, plus architecture-rule tests
- Integration: Prisma data layer, API routes, and all server actions
- Component: UI primitives and form components (jsdom + Testing Library)
- 371 tests passing
2026-08-06 02:27:20 +02:00

38 lines
1.4 KiB
TypeScript

import { Activity } from "lucide-react";
import { render, screen } from "@testing-library/react";
import { describe, expect, it } from "vitest";
import { DashboardCard } from "@/components/dashboard/dashboard-card";
import { StatsCard } from "@/components/dashboard/stats-card";
describe("StatsCard", () => {
it("renders the title and value", () => {
render(<StatsCard title="Visitors" value="1,234" icon={Activity} />);
expect(screen.getByText("Visitors")).toBeInTheDocument();
expect(screen.getByText("1,234")).toBeInTheDocument();
});
it("renders an optional description and footer", () => {
render(
<StatsCard title="T" value="V" description="Up 5%" footer={<span>footer</span>} />,
);
expect(screen.getByText("Up 5%")).toBeInTheDocument();
expect(screen.getByText("footer")).toBeInTheDocument();
});
it("omits the icon container when no icon is provided", () => {
const { container } = render(<StatsCard title="T" value="V" />);
expect(container.querySelector("svg")).toBeNull();
});
});
describe("DashboardCard", () => {
it("passes its props through to a StatsCard", () => {
render(<DashboardCard title="Sales" value="42" description="today" icon={Activity} />);
expect(screen.getByText("Sales")).toBeInTheDocument();
expect(screen.getByText("42")).toBeInTheDocument();
expect(screen.getByText("today")).toBeInTheDocument();
});
});