38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
import { describe, expect, test } from "bun:test";
|
|
import { screen } from "@testing-library/react";
|
|
import { createElement } from "react";
|
|
|
|
import { APP } from "../../src/shared/app";
|
|
import { App } from "../../src/web/app";
|
|
import { installFetchMock, jsonResponse, mockMetaResponse, renderWithProviders } from "./test-utils";
|
|
|
|
function mockSettingsResponse(): Response {
|
|
return jsonResponse({ theme: "system" });
|
|
}
|
|
|
|
describe("App", () => {
|
|
test("渲染管理台入口和品牌", () => {
|
|
installFetchMock((call) => {
|
|
if (call.url.includes("/api/settings")) return mockSettingsResponse();
|
|
return mockMetaResponse();
|
|
});
|
|
|
|
renderWithProviders(createElement(App));
|
|
|
|
expect(screen.getByText(APP.title)).not.toBeNull();
|
|
expect(screen.getByText("管理台")).not.toBeNull();
|
|
});
|
|
|
|
test("渲染管理台侧边栏菜单项", () => {
|
|
installFetchMock((call) => {
|
|
if (call.url.includes("/api/settings")) return mockSettingsResponse();
|
|
return mockMetaResponse();
|
|
});
|
|
|
|
renderWithProviders(createElement(App));
|
|
|
|
expect(screen.getAllByText("总览").length).toBeGreaterThan(0);
|
|
expect(screen.getAllByText("项目管理").length).toBeGreaterThan(0);
|
|
});
|
|
});
|