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/Gaming/LeftTime.test.tsx | 47 ++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 frontend/app/components/Gaming/LeftTime.test.tsx (limited to 'frontend/app/components/Gaming') diff --git a/frontend/app/components/Gaming/LeftTime.test.tsx b/frontend/app/components/Gaming/LeftTime.test.tsx new file mode 100644 index 0000000..742d8eb --- /dev/null +++ b/frontend/app/components/Gaming/LeftTime.test.tsx @@ -0,0 +1,47 @@ +/** + * @vitest-environment jsdom + */ +import { cleanup, render, screen } from "@testing-library/react"; +import { afterEach, describe, expect, test } from "vitest"; +import LeftTime from "./LeftTime"; + +afterEach(() => { + cleanup(); +}); + +describe("LeftTime", () => { + test("renders MM:SS format for short durations", () => { + render(); + expect(screen.getByText("01:05")).toBeDefined(); + }); + + test("renders 00:00 for zero seconds", () => { + render(); + expect(screen.getByText("00:00")).toBeDefined(); + }); + + test("renders MM:SS with leading zeros", () => { + render(); + expect(screen.getByText("00:05")).toBeDefined(); + }); + + test("renders 59:59 for max MM:SS range", () => { + render(); + expect(screen.getByText("59:59")).toBeDefined(); + }); + + test("renders long format with hours", () => { + render(); + expect(screen.getByText("1h 1m 1s")).toBeDefined(); + }); + + test("renders long format with days", () => { + render(); + expect(screen.getByText("1d 1h 1m 1s")).toBeDefined(); + }); + + test("renders long format omitting zero day and minute", () => { + render(); + expect(screen.getByText("1h 5s")).toBeDefined(); + }); +}); -- cgit v1.3.1