Move tables test to specific struct tree spec file

This commit is contained in:
Edoardo Cavazza 2025-10-20 09:47:21 +02:00
parent d04832a82f
commit 17cdd9b1e7
3 changed files with 29 additions and 42 deletions

View File

@ -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",

View File

@ -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 () {

View File

@ -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();
});
});