mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 09:50:42 +00:00
test: share feishu docx batch fixture
This commit is contained in:
@@ -31,6 +31,20 @@ function createCountingIterable<T>(values: T[]) {
|
||||
};
|
||||
}
|
||||
|
||||
function createSuccessfulDocxDescendantCreateMock() {
|
||||
return vi.fn(
|
||||
async (params?: DocxDescendantCreateParams): Promise<DocxDescendantCreateResponse> => ({
|
||||
code: 0,
|
||||
data: {
|
||||
children: (params?.data?.children_id ?? []).map((id) => ({
|
||||
block_id: id,
|
||||
block_type: 2,
|
||||
})),
|
||||
},
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
describe("insertBlocksInBatches", () => {
|
||||
it("builds the source block map once for large flat trees", async () => {
|
||||
const blockCount = BATCH_SIZE + 200;
|
||||
@@ -39,17 +53,7 @@ describe("insertBlocksInBatches", () => {
|
||||
block_type: 2,
|
||||
}));
|
||||
const counting = createCountingIterable(blocks);
|
||||
const createMock = vi.fn(
|
||||
async (params?: DocxDescendantCreateParams): Promise<DocxDescendantCreateResponse> => ({
|
||||
code: 0,
|
||||
data: {
|
||||
children: (params?.data?.children_id ?? []).map((id) => ({
|
||||
block_id: id,
|
||||
block_type: 2,
|
||||
})),
|
||||
},
|
||||
}),
|
||||
);
|
||||
const createMock = createSuccessfulDocxDescendantCreateMock();
|
||||
const client = createDocxDescendantClient((params) => createMock(params));
|
||||
|
||||
const result = await insertBlocksInBatches(
|
||||
@@ -67,17 +71,7 @@ describe("insertBlocksInBatches", () => {
|
||||
});
|
||||
|
||||
it("keeps nested descendants grouped with their root blocks", async () => {
|
||||
const createMock = vi.fn(
|
||||
async (params?: DocxDescendantCreateParams): Promise<DocxDescendantCreateResponse> => ({
|
||||
code: 0,
|
||||
data: {
|
||||
children: (params?.data?.children_id ?? []).map((id) => ({
|
||||
block_id: id,
|
||||
block_type: 2,
|
||||
})),
|
||||
},
|
||||
}),
|
||||
);
|
||||
const createMock = createSuccessfulDocxDescendantCreateMock();
|
||||
const client = createDocxDescendantClient((params) => createMock(params));
|
||||
const blocks: FeishuDocxBlock[] = [
|
||||
{ block_id: "root_a", block_type: 1, children: ["child_a"] },
|
||||
|
||||
Reference in New Issue
Block a user