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();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user