From 2f3583212f470f454a8bd4942a36742be92ad62b Mon Sep 17 00:00:00 2001
From: nsfisis <nsfisis@gmail.com>
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 <noreply@anthropic.com>
---
 frontend/app/components/PlayerNameAndIcon.test.tsx | 39 ++++++++++++++++++++++
 1 file changed, 39 insertions(+)
 create mode 100644 frontend/app/components/PlayerNameAndIcon.test.tsx

(limited to 'frontend/app/components/PlayerNameAndIcon.test.tsx')

diff --git a/frontend/app/components/PlayerNameAndIcon.test.tsx b/frontend/app/components/PlayerNameAndIcon.test.tsx
new file mode 100644
index 0000000..5a9dd49
--- /dev/null
+++ b/frontend/app/components/PlayerNameAndIcon.test.tsx
@@ -0,0 +1,39 @@
+/**
+ * @vitest-environment jsdom
+ */
+import { cleanup, render, screen } from "@testing-library/react";
+import { afterEach, describe, expect, test } from "vitest";
+import PlayerNameAndIcon from "./PlayerNameAndIcon";
+
+afterEach(() => {
+	cleanup();
+});
+
+describe("PlayerNameAndIcon", () => {
+	test("renders display name", () => {
+		render(
+			<PlayerNameAndIcon
+				profile={{ id: 1, displayName: "Alice", iconPath: null }}
+			/>,
+		);
+		expect(screen.getByText("Alice")).toBeDefined();
+	});
+
+	test("does not render icon when iconPath is null", () => {
+		render(
+			<PlayerNameAndIcon
+				profile={{ id: 1, displayName: "Bob", iconPath: null }}
+			/>,
+		);
+		expect(screen.queryByRole("img")).toBeNull();
+	});
+
+	test("renders icon when iconPath is provided", () => {
+		render(
+			<PlayerNameAndIcon
+				profile={{ id: 1, displayName: "Carol", iconPath: "icons/carol.png" }}
+			/>,
+		);
+		expect(screen.getByAltText("Carol のアイコン")).toBeDefined();
+	});
+});
-- 
cgit v1.3.1

