From 03b10e97d35f827acca5660cf5fafd0747ec116c Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Mon, 20 Apr 2026 21:25:28 +0100 Subject: [PATCH] test: share feishu docx batch fixture --- .../feishu/src/docx-batch-insert.test.ts | 38 ++++++++----------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/extensions/feishu/src/docx-batch-insert.test.ts b/extensions/feishu/src/docx-batch-insert.test.ts index 2b3f9f39db0..a2177744538 100644 --- a/extensions/feishu/src/docx-batch-insert.test.ts +++ b/extensions/feishu/src/docx-batch-insert.test.ts @@ -31,6 +31,20 @@ function createCountingIterable(values: T[]) { }; } +function createSuccessfulDocxDescendantCreateMock() { + return vi.fn( + async (params?: DocxDescendantCreateParams): Promise => ({ + 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 => ({ - 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 => ({ - 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"] },