48 lines
1.6 KiB
TypeScript
48 lines
1.6 KiB
TypeScript
/* eslint-disable @typescript-eslint/require-await */
|
|
import { screen } from "@testing-library/react";
|
|
import { describe, expect, test } from "bun:test";
|
|
import { createElement } from "react";
|
|
|
|
import { APP } from "../../src/shared/app";
|
|
import { App } from "../../src/web/app";
|
|
import { renderWithProviders } from "./test-utils";
|
|
|
|
describe("App", () => {
|
|
test("渲染 Layout 骨架和品牌名", () => {
|
|
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(App));
|
|
|
|
expect(screen.getByText(APP.title)).not.toBeNull();
|
|
expect(screen.getByText("系统")).not.toBeNull();
|
|
expect(screen.getByText("明亮")).not.toBeNull();
|
|
expect(screen.getByText("黑暗")).not.toBeNull();
|
|
});
|
|
|
|
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(App));
|
|
|
|
expect(screen.getAllByText("仪表盘").length).toBeGreaterThan(0);
|
|
expect(screen.getAllByText("用户管理").length).toBeGreaterThan(0);
|
|
expect(screen.getAllByText("系统设置").length).toBeGreaterThan(0);
|
|
});
|
|
});
|