30 lines
1.1 KiB
TypeScript
30 lines
1.1 KiB
TypeScript
import { screen } from "@testing-library/react";
|
|
import { describe, expect, test } from "bun:test";
|
|
import { createElement } from "react";
|
|
|
|
import type { Material } from "../../../../src/web/features/inbox/types";
|
|
|
|
import { MaterialContent } from "../../../../src/web/features/inbox/components/MaterialContent";
|
|
import { renderWithProviders } from "../../test-utils";
|
|
|
|
const MOCK_MATERIAL: Material = {
|
|
associatedDate: "2026-06-03",
|
|
createdAt: new Date().toISOString(),
|
|
description: "详细描述内容",
|
|
id: "test-id",
|
|
};
|
|
|
|
describe("MaterialContent", () => {
|
|
test("未选中时显示空状态提示", () => {
|
|
renderWithProviders(createElement(MaterialContent, { material: null }));
|
|
expect(screen.getByText("请在左侧选择素材")).not.toBeNull();
|
|
});
|
|
|
|
test("选中时展示素材详情", () => {
|
|
renderWithProviders(createElement(MaterialContent, { material: MOCK_MATERIAL }));
|
|
expect(screen.getByText("素材详情")).not.toBeNull();
|
|
expect(screen.getByText("详细描述内容")).not.toBeNull();
|
|
expect(screen.getByText("2026-06-03")).not.toBeNull();
|
|
});
|
|
});
|