You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.2 KiB
TypeScript

// frontend/tests/Shell.test.tsx — 조건부 셸: /login 만 풀스크린(Topbar 없음), 그 외엔 Topbar 렌더
import { render, cleanup } from "@testing-library/react";
import { describe, expect, it, vi, afterEach } from "vitest";
let path = "/dashboard";
vi.mock("next/navigation", () => ({ usePathname: () => path }));
import { Shell } from "@/components/Shell";
describe("Shell", () => {
afterEach(() => {
cleanup();
});
it("일반 경로(/dashboard)는 Topbar + .shell-page 를 렌더한다", () => {
path = "/dashboard";
const { container } = render(
<Shell>
<div data-testid="child" />
</Shell>,
);
expect(container.querySelector(".shell-page")).toBeTruthy();
expect(container.querySelector(".topbar")).toBeTruthy();
});
it("/login 은 풀스크린 — Topbar/.shell-page 없이 children 만 렌더한다", () => {
path = "/login";
const { container } = render(
<Shell>
<div data-testid="child" className="loginchild" />
</Shell>,
);
expect(container.querySelector(".shell-page")).toBeFalsy();
expect(container.querySelector(".topbar")).toBeFalsy();
expect(container.querySelector(".loginchild")).toBeTruthy();
});
});