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/hooks/usePageTitle.test.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 frontend/app/hooks/usePageTitle.test.ts (limited to 'frontend/app/hooks/usePageTitle.test.ts') diff --git a/frontend/app/hooks/usePageTitle.test.ts b/frontend/app/hooks/usePageTitle.test.ts new file mode 100644 index 0000000..2e1a3ec --- /dev/null +++ b/frontend/app/hooks/usePageTitle.test.ts @@ -0,0 +1,23 @@ +/** + * @vitest-environment jsdom + */ +import { renderHook } from "@testing-library/react"; +import { describe, expect, test } from "vitest"; +import { usePageTitle } from "./usePageTitle"; + +describe("usePageTitle", () => { + test("sets document title", () => { + renderHook(() => usePageTitle("Test Page")); + expect(document.title).toBe("Test Page"); + }); + + test("updates document title when value changes", () => { + const { rerender } = renderHook(({ title }) => usePageTitle(title), { + initialProps: { title: "First" }, + }); + expect(document.title).toBe("First"); + + rerender({ title: "Second" }); + expect(document.title).toBe("Second"); + }); +}); -- cgit v1.3.1