Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/app/App.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { render, screen } from "@testing-library/react";
import { cleanup, fireEvent, render, screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { afterEach, describe, expect, it, vi } from "vitest";

Expand All @@ -23,6 +23,7 @@ function renderRoute(path: string) {
}

afterEach(() => {
cleanup();
clearAdminSession();
window.sessionStorage.clear();
vi.unstubAllGlobals();
Expand Down Expand Up @@ -76,16 +77,15 @@ describe("App routes", () => {
});

it("약관 관리 화면에 약관 목록을 표시한다", async () => {
const user = userEvent.setup();
mockAdminFetch();
signInTestSession();
renderRoute("/admin/terms");

expect(await screen.findByRole("heading", { name: "약관 관리" })).toBeInTheDocument();
expect(await screen.findByRole("cell", { name: "서비스 이용약관 v1" })).toBeInTheDocument();
expect(await screen.findByText("서비스 이용약관 v1")).toBeInTheDocument();
expect(screen.queryByText("서비스 이용약관 본문입니다.")).not.toBeInTheDocument();

await user.click(screen.getByRole("button", { name: "본문 보기" }));
fireEvent.click(screen.getByRole("button", { name: "본문 보기" }));

expect(await screen.findByText("서비스 이용약관 본문입니다.")).toBeInTheDocument();
});
Expand Down
7 changes: 7 additions & 0 deletions src/test/setup.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import "@testing-library/jest-dom/vitest";

const getComputedStyle = window.getComputedStyle.bind(window);

Object.defineProperty(window, "getComputedStyle", {
writable: true,
value: (element: Element) => getComputedStyle(element)
});

Object.defineProperty(window, "matchMedia", {
writable: true,
value: (query: string) => ({
Expand Down
Loading