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 --- frontend/app/components/SubmitButton.test.tsx | 41 +++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 frontend/app/components/SubmitButton.test.tsx (limited to 'frontend/app/components/SubmitButton.test.tsx') diff --git a/frontend/app/components/SubmitButton.test.tsx b/frontend/app/components/SubmitButton.test.tsx new file mode 100644 index 0000000..ebf3416 --- /dev/null +++ b/frontend/app/components/SubmitButton.test.tsx @@ -0,0 +1,41 @@ +/** + * @vitest-environment jsdom + */ +import { cleanup, render, screen } from "@testing-library/react"; +import { afterEach, describe, expect, test } from "vitest"; +import SubmitButton from "./SubmitButton"; + +afterEach(() => { + cleanup(); +}); + +describe("SubmitButton", () => { + test("renders children text", () => { + render(Submit); + expect(screen.getByText("Submit")).toBeDefined(); + }); + + test("renders as a button element", () => { + render(Click); + const button = screen.getByText("Click"); + expect(button.tagName).toBe("BUTTON"); + }); + + test("can be disabled", () => { + render(Submit); + const button = screen.getByText("Submit") as HTMLButtonElement; + expect(button.disabled).toBe(true); + }); + + test("is not disabled by default", () => { + render(Submit); + const button = screen.getByText("Submit") as HTMLButtonElement; + expect(button.disabled).toBe(false); + }); + + test("has sky-600 background styling", () => { + render(Submit); + const button = screen.getByText("Submit"); + expect(button.className).toContain("bg-sky-600"); + }); +}); -- cgit v1.3.1