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.

39 lines
2.0 KiB
TypeScript

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

// frontend/tests/notify/GuardPanel.test.tsx — 토글 on/off 클래스 + 문구 전환
import { fireEvent, render, screen } from "@testing-library/react";
import { describe, expect, it, vi } from "vitest";
import { GuardPanel } from "@/components/notify/GuardPanel";
import type { Digest, NotifyGuard } from "@/lib/types";
const guardOn: NotifyGuard = { on: true, until: "16:00", held: 4, quiet: "22:30 07:00" };
const digests: Digest[] = [
{ id: "dg-am", time: "09:00", name: "아침 브리핑", desc: "밤사이 변화", count: 11, done: true },
{ id: "dg-eve", time: "18:30", name: "저녁 다이제스트", desc: "소식", count: 12, done: false },
];
describe("GuardPanel", () => {
it("on 상태 — '딥 워크 보호 중' + sw.on 클래스", () => {
render(<GuardPanel guard={guardOn} digests={digests} onToggle={() => {}} />);
expect(screen.getByText(/딥 워크 보호 중 — 16:00까지/)).toBeInTheDocument();
expect(screen.getByLabelText("집중 보호 켜기/끄기")).toHaveClass("on");
});
it("off 상태 — '보호 꺼짐' + sw.on 없음", () => {
render(<GuardPanel guard={{ ...guardOn, on: false }} digests={digests} onToggle={() => {}} />);
expect(screen.getByText("보호 꺼짐")).toBeInTheDocument();
expect(screen.getByLabelText("집중 보호 켜기/끄기")).not.toHaveClass("on");
});
it("토글 클릭 시 onToggle 호출", () => {
const onToggle = vi.fn();
render(<GuardPanel guard={guardOn} digests={digests} onToggle={onToggle} />);
fireEvent.click(screen.getByLabelText("집중 보호 켜기/끄기"));
expect(onToggle).toHaveBeenCalled();
});
it("묶음 배달 — done 행은 dg2-row done + '— 전달됨'", () => {
render(<GuardPanel guard={guardOn} digests={digests} onToggle={() => {}} />);
expect(screen.getByText("아침 브리핑 — 전달됨").closest(".dg2-row")).toHaveClass("done");
expect(screen.getByText("저녁 다이제스트").closest(".dg2-row")).not.toHaveClass("done");
});
});