feat: 初始提交
This commit is contained in:
24
tests/web/routes/404.test.tsx
Normal file
24
tests/web/routes/404.test.tsx
Normal file
@@ -0,0 +1,24 @@
|
||||
import { screen } from "@testing-library/react";
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { createElement } from "react";
|
||||
|
||||
import { NotFoundPage } from "../../../src/web/pages/404";
|
||||
import { renderWithProviders } from "../test-utils";
|
||||
|
||||
describe("NotFoundPage", () => {
|
||||
test("渲染 404 页面", () => {
|
||||
renderWithProviders(createElement(NotFoundPage));
|
||||
|
||||
expect(screen.getByText("404")).not.toBeNull();
|
||||
expect(screen.getByText("您访问的页面不存在")).not.toBeNull();
|
||||
expect(screen.getByText("返回首页")).not.toBeNull();
|
||||
});
|
||||
|
||||
test("返回首页按钮存在且可点击", () => {
|
||||
renderWithProviders(createElement(NotFoundPage));
|
||||
|
||||
const button = screen.getByText("返回首页");
|
||||
expect(button).not.toBeNull();
|
||||
expect(button.closest("button")).not.toBeNull();
|
||||
});
|
||||
});
|
||||
25
tests/web/routes/dashboard.test.tsx
Normal file
25
tests/web/routes/dashboard.test.tsx
Normal file
@@ -0,0 +1,25 @@
|
||||
/* eslint-disable @typescript-eslint/require-await */
|
||||
import { screen } from "@testing-library/react";
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { createElement } from "react";
|
||||
|
||||
import { DashboardPage } from "../../../src/web/pages/dashboard";
|
||||
import { renderWithProviders } from "../test-utils";
|
||||
|
||||
describe("DashboardPage", () => {
|
||||
test("渲染欢迎信息", () => {
|
||||
window.fetch = (async () => {
|
||||
return new Response(
|
||||
JSON.stringify({ ok: true, service: "test-app", timestamp: new Date().toISOString(), version: "0.1.0" }),
|
||||
{
|
||||
headers: { "Content-Type": "application/json" },
|
||||
status: 200,
|
||||
},
|
||||
);
|
||||
}) as unknown as typeof fetch;
|
||||
|
||||
renderWithProviders(createElement(DashboardPage));
|
||||
|
||||
expect(screen.getByText(/欢迎使用/)).not.toBeNull();
|
||||
});
|
||||
});
|
||||
15
tests/web/routes/settings.test.tsx
Normal file
15
tests/web/routes/settings.test.tsx
Normal file
@@ -0,0 +1,15 @@
|
||||
import { screen } from "@testing-library/react";
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { createElement } from "react";
|
||||
|
||||
import { SettingsPage } from "../../../src/web/pages/settings";
|
||||
import { renderWithProviders } from "../test-utils";
|
||||
|
||||
describe("SettingsPage", () => {
|
||||
test("渲染系统设置页面", () => {
|
||||
renderWithProviders(createElement(SettingsPage));
|
||||
|
||||
expect(screen.getByText("系统设置")).not.toBeNull();
|
||||
expect(screen.getByText("页面建设中...")).not.toBeNull();
|
||||
});
|
||||
});
|
||||
15
tests/web/routes/users.test.tsx
Normal file
15
tests/web/routes/users.test.tsx
Normal file
@@ -0,0 +1,15 @@
|
||||
import { screen } from "@testing-library/react";
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { createElement } from "react";
|
||||
|
||||
import { UsersPage } from "../../../src/web/pages/users";
|
||||
import { renderWithProviders } from "../test-utils";
|
||||
|
||||
describe("UsersPage", () => {
|
||||
test("渲染用户管理页面", () => {
|
||||
renderWithProviders(createElement(UsersPage));
|
||||
|
||||
expect(screen.getByText("用户管理")).not.toBeNull();
|
||||
expect(screen.getByText("页面建设中...")).not.toBeNull();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user