fix: 修正 markdown-to-jsx 导入方式 + 新增 formatDateLabel 日期工具函数
- TextPart: default import → named import - MaterialCard: 使用 formatDateLabel 显示今天/昨天/日期 - 清理旧测试文件,新增 ResourceTable 测试
This commit is contained in:
@@ -1,40 +0,0 @@
|
||||
import { screen } from "@testing-library/react";
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { createElement } from "react";
|
||||
|
||||
import type { Material } from "../../../../src/shared/api";
|
||||
|
||||
import { MaterialContent } from "../../../../src/web/features/inbox/components/MaterialContent";
|
||||
import { renderWithProviders } from "../../test-utils";
|
||||
|
||||
const MOCK_MATERIAL: Material = {
|
||||
associatedDate: "2026-06-03",
|
||||
createdAt: "2026-06-03T00:00:00.000Z",
|
||||
description: "详细描述内容",
|
||||
id: "test-id",
|
||||
projectId: "project-1",
|
||||
status: "pending",
|
||||
updatedAt: "2026-06-03T00:00:00.000Z",
|
||||
};
|
||||
|
||||
describe("MaterialContent", () => {
|
||||
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();
|
||||
expect(screen.getByText("待审核")).not.toBeNull();
|
||||
});
|
||||
|
||||
test("展示已通过状态", () => {
|
||||
const approved: Material = { ...MOCK_MATERIAL, status: "approved" };
|
||||
renderWithProviders(createElement(MaterialContent, { material: approved }));
|
||||
expect(screen.getByText("已通过")).not.toBeNull();
|
||||
});
|
||||
|
||||
test("展示已放弃状态", () => {
|
||||
const discarded: Material = { ...MOCK_MATERIAL, status: "discarded" };
|
||||
renderWithProviders(createElement(MaterialContent, { material: discarded }));
|
||||
expect(screen.getByText("已放弃")).not.toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -74,7 +74,7 @@ describe("MaterialList", () => {
|
||||
expect(onAddClick).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
test("加载中显示 Spin", () => {
|
||||
test("加载中显示 Skeleton", () => {
|
||||
renderWithProviders(
|
||||
createElement(MaterialList, {
|
||||
loading: true,
|
||||
@@ -85,6 +85,6 @@ describe("MaterialList", () => {
|
||||
selectedId: null,
|
||||
}),
|
||||
);
|
||||
expect(document.querySelector(".ant-spin")).not.toBeNull();
|
||||
expect(document.querySelector(".ant-skeleton")).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user