From 17cdd9b1e781a261c68ae697bc82abfa6ff896cb Mon Sep 17 00:00:00 2001 From: Edoardo Cavazza Date: Mon, 20 Oct 2025 09:47:21 +0200 Subject: [PATCH] Move tables test to specific struct tree spec file --- test/test_manifest.json | 6 ------ test/unit/api_spec.js | 35 ----------------------------------- test/unit/struct_tree_spec.js | 30 +++++++++++++++++++++++++++++- 3 files changed, 29 insertions(+), 42 deletions(-) diff --git a/test/test_manifest.json b/test/test_manifest.json index afc29a290..03d1f1d71 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -1676,12 +1676,6 @@ "lastPage": 1, "type": "eq" }, - { "id": "issue20324", - "file": "pdfs/issue20324.pdf", - "md5": "13250232aa91444f983279581d9c02d6", - "rounds": 1, - "type": "eq" - }, { "id": "issue13561_reduced", "file": "pdfs/issue13561_reduced.pdf", diff --git a/test/unit/api_spec.js b/test/unit/api_spec.js index 9e975cb00..a8e0fbc07 100644 --- a/test/unit/api_spec.js +++ b/test/unit/api_spec.js @@ -5076,41 +5076,6 @@ Caron Broadcasting, Inc., an Ohio corporation (“Lessee”).`) canvasFactory.destroy(canvasAndCtx); await loadingTask.destroy(); }); - - it("should collect all list and table items in StructTree", async function() { - const findNodes = (node, check) => { - const results = []; - if (check(node)) { - results.push(node); - } - if (node.children) { - for (const child of node.children) { - results.push(...findNodes(child, check)); - } - } - return results; - }; - const loadingTask = getDocument(buildGetDocumentParams("issue20324.pdf")); - - const pdfDoc = await loadingTask.promise; - const page = await pdfDoc.getPage(1); - const tree = await page.getStructTree({ - includeMarkedContent: true, - }); - const cells = findNodes( - tree, - node => node.role === "TD" - ); - expect(cells.length).toEqual(4); - - const listItems = findNodes( - tree, - node => node.role === "LI" - ); - expect(listItems.length).toEqual(4); - - await loadingTask.destroy(); - }); }); describe("Multiple `getDocument` instances", function () { diff --git a/test/unit/struct_tree_spec.js b/test/unit/struct_tree_spec.js index ca722b854..9b138dc70 100644 --- a/test/unit/struct_tree_spec.js +++ b/test/unit/struct_tree_spec.js @@ -258,7 +258,7 @@ describe("struct tree", function () { await loadingTask.destroy(); }); - it("parses structure with some MathML in MS Office specific entry", async function () { + it("parses structure with some MathML in MS Office specific entry", async function() { const filename = "bug1937438_from_word.pdf"; const params = buildGetDocumentParams(filename); const loadingTask = getDocument(params); @@ -300,6 +300,34 @@ describe("struct tree", function () { }, struct ); + }); + + it("should collect all list and table items in StructTree", async function () { + const findNodes = (node, check) => { + const results = []; + if (check(node)) { + results.push(node); + } + if (node.children) { + for (const child of node.children) { + results.push(...findNodes(child, check)); + } + } + return results; + }; + const loadingTask = getDocument(buildGetDocumentParams("issue20324.pdf")); + + const pdfDoc = await loadingTask.promise; + const page = await pdfDoc.getPage(1); + const tree = await page.getStructTree({ + includeMarkedContent: true, + }); + const cells = findNodes(tree, node => node.role === "TD"); + expect(cells.length).toEqual(4); + + const listItems = findNodes(tree, node => node.role === "LI"); + expect(listItems.length).toEqual(4); + await loadingTask.destroy(); }); });