aboutsummaryrefslogtreecommitdiffhomepage
path: root/frontend/app
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-02-16 23:10:11 +0900
committernsfisis <nsfisis@gmail.com>2026-02-16 23:14:10 +0900
commit1699d2bf679e336cc89ccab5bb8ef7e1101e721d (patch)
treedb31556771736e4aa178d9c4aba19c135b62d8d0 /frontend/app
parentefe05c1444963c046ab91bf54fa51a794bda58c0 (diff)
downloadphperkaigi-2026-albatross-1699d2bf679e336cc89ccab5bb8ef7e1101e721d.tar.gz
phperkaigi-2026-albatross-1699d2bf679e336cc89ccab5bb8ef7e1101e721d.tar.zst
phperkaigi-2026-albatross-1699d2bf679e336cc89ccab5bb8ef7e1101e721d.zip
test(frontend): add Vitest test infrastructure and sample tests
Set up Vitest with @testing-library/react and jsdom for frontend unit testing. Add sample tests for config.ts and BorderedContainer. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'frontend/app')
-rw-r--r--frontend/app/components/BorderedContainer.test.tsx33
-rw-r--r--frontend/app/config.test.ts16
2 files changed, 49 insertions, 0 deletions
diff --git a/frontend/app/components/BorderedContainer.test.tsx b/frontend/app/components/BorderedContainer.test.tsx
new file mode 100644
index 0000000..2d1b663
--- /dev/null
+++ b/frontend/app/components/BorderedContainer.test.tsx
@@ -0,0 +1,33 @@
+/**
+ * @vitest-environment jsdom
+ */
+import { cleanup, render, screen } from "@testing-library/react";
+import { afterEach, describe, expect, test } from "vitest";
+import BorderedContainer from "./BorderedContainer";
+
+afterEach(() => {
+ cleanup();
+});
+
+describe("BorderedContainer", () => {
+ test("renders children", () => {
+ render(<BorderedContainer>Hello World</BorderedContainer>);
+ expect(screen.getByText("Hello World")).toBeDefined();
+ });
+
+ test("applies custom className", () => {
+ render(
+ <BorderedContainer className="custom-class">Content</BorderedContainer>,
+ );
+ const container = screen.getByText("Content").closest("div");
+ expect(container?.className).toContain("custom-class");
+ });
+
+ test("has default border styling", () => {
+ render(<BorderedContainer>Styled</BorderedContainer>);
+ const container = screen.getByText("Styled").closest("div");
+ expect(container?.className).toContain("border-2");
+ expect(container?.className).toContain("border-blue-600");
+ expect(container?.className).toContain("rounded-xl");
+ });
+});
diff --git a/frontend/app/config.test.ts b/frontend/app/config.test.ts
new file mode 100644
index 0000000..6989635
--- /dev/null
+++ b/frontend/app/config.test.ts
@@ -0,0 +1,16 @@
+import { describe, expect, test } from "vitest";
+import { API_BASE_PATH, APP_NAME, BASE_PATH } from "./config";
+
+describe("config", () => {
+ test("BASE_PATH defaults to /", () => {
+ expect(BASE_PATH).toBe("/");
+ });
+
+ test("API_BASE_PATH is based on BASE_PATH", () => {
+ expect(API_BASE_PATH).toBe(`${BASE_PATH}api/`);
+ });
+
+ test("APP_NAME is defined", () => {
+ expect(APP_NAME).toBeTruthy();
+ });
+});