From 2f3583212f470f454a8bd4942a36742be92ad62b Mon Sep 17 00:00:00 2001 From: nsfisis Date: Tue, 17 Feb 2026 20:32:58 +0900 Subject: test(frontend): add comprehensive tests for components, hooks, and state Add 84 new tests covering Jotai atoms (play/watch state transitions, game timing, score management), utility functions (calcCodeSize, checkGameResultKind), UI components (SubmitStatusLabel, LeftTime, SubmitButton, InputText, BorderedContainerWithCaption, FoldableBorderedContainerWithCaption, UserIcon, PlayerNameAndIcon), and the usePageTitle hook. Co-Authored-By: Claude Opus 4.6 --- .../FoldableBorderedContainerWithCaption.test.tsx | 56 ++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 frontend/app/components/FoldableBorderedContainerWithCaption.test.tsx (limited to 'frontend/app/components/FoldableBorderedContainerWithCaption.test.tsx') diff --git a/frontend/app/components/FoldableBorderedContainerWithCaption.test.tsx b/frontend/app/components/FoldableBorderedContainerWithCaption.test.tsx new file mode 100644 index 0000000..a4434ff --- /dev/null +++ b/frontend/app/components/FoldableBorderedContainerWithCaption.test.tsx @@ -0,0 +1,56 @@ +/** + * @vitest-environment jsdom + */ +import { cleanup, fireEvent, render, screen } from "@testing-library/react"; +import { afterEach, describe, expect, test } from "vitest"; +import FoldableBorderedContainerWithCaption from "./FoldableBorderedContainerWithCaption"; + +afterEach(() => { + cleanup(); +}); + +describe("FoldableBorderedContainerWithCaption", () => { + test("renders caption", () => { + render( + + Content + , + ); + expect(screen.getByText("Foldable Title")).toBeDefined(); + }); + + test("shows children by default (open state)", () => { + render( + +
Visible
+
, + ); + const child = screen.getByTestId("child"); + expect(child.parentElement?.className).not.toContain("hidden"); + }); + + test("hides children when toggle button is clicked", () => { + render( + +
Content
+
, + ); + const toggleButton = screen.getByRole("button"); + fireEvent.click(toggleButton); + const child = screen.getByTestId("child"); + expect(child.parentElement?.className).toContain("hidden"); + }); + + test("shows children again when toggle button is clicked twice", () => { + render( + +
Content
+
, + ); + const toggleButton = screen.getByRole("button"); + fireEvent.click(toggleButton); + fireEvent.click(toggleButton); + const child = screen.getByTestId("child"); + expect(child.parentElement?.className).not.toContain("hidden"); + }); +}); -- cgit v1.3.1