aboutsummaryrefslogtreecommitdiffhomepage
path: root/frontend/app/components/SubmitButton.test.tsx
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-02-17 20:32:58 +0900
committernsfisis <nsfisis@gmail.com>2026-02-17 20:32:58 +0900
commit2f3583212f470f454a8bd4942a36742be92ad62b (patch)
tree521313b18404adcbae7bc6ddf9ab415a1d959e9b /frontend/app/components/SubmitButton.test.tsx
parent602cca615c733c79bc3930f37408a0e71ee40e62 (diff)
downloadphperkaigi-2026-albatross-2f3583212f470f454a8bd4942a36742be92ad62b.tar.gz
phperkaigi-2026-albatross-2f3583212f470f454a8bd4942a36742be92ad62b.tar.zst
phperkaigi-2026-albatross-2f3583212f470f454a8bd4942a36742be92ad62b.zip
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 <noreply@anthropic.com>
Diffstat (limited to 'frontend/app/components/SubmitButton.test.tsx')
-rw-r--r--frontend/app/components/SubmitButton.test.tsx41
1 files changed, 41 insertions, 0 deletions
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(<SubmitButton>Submit</SubmitButton>);
+ expect(screen.getByText("Submit")).toBeDefined();
+ });
+
+ test("renders as a button element", () => {
+ render(<SubmitButton>Click</SubmitButton>);
+ const button = screen.getByText("Click");
+ expect(button.tagName).toBe("BUTTON");
+ });
+
+ test("can be disabled", () => {
+ render(<SubmitButton disabled>Submit</SubmitButton>);
+ const button = screen.getByText("Submit") as HTMLButtonElement;
+ expect(button.disabled).toBe(true);
+ });
+
+ test("is not disabled by default", () => {
+ render(<SubmitButton>Submit</SubmitButton>);
+ const button = screen.getByText("Submit") as HTMLButtonElement;
+ expect(button.disabled).toBe(false);
+ });
+
+ test("has sky-600 background styling", () => {
+ render(<SubmitButton>Submit</SubmitButton>);
+ const button = screen.getByText("Submit");
+ expect(button.className).toContain("bg-sky-600");
+ });
+});