Move tables test to specific struct tree spec file
This commit is contained in:
parent
d04832a82f
commit
17cdd9b1e7
@ -1676,12 +1676,6 @@
|
|||||||
"lastPage": 1,
|
"lastPage": 1,
|
||||||
"type": "eq"
|
"type": "eq"
|
||||||
},
|
},
|
||||||
{ "id": "issue20324",
|
|
||||||
"file": "pdfs/issue20324.pdf",
|
|
||||||
"md5": "13250232aa91444f983279581d9c02d6",
|
|
||||||
"rounds": 1,
|
|
||||||
"type": "eq"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"id": "issue13561_reduced",
|
"id": "issue13561_reduced",
|
||||||
"file": "pdfs/issue13561_reduced.pdf",
|
"file": "pdfs/issue13561_reduced.pdf",
|
||||||
|
|||||||
@ -5076,41 +5076,6 @@ Caron Broadcasting, Inc., an Ohio corporation (“Lessee”).`)
|
|||||||
canvasFactory.destroy(canvasAndCtx);
|
canvasFactory.destroy(canvasAndCtx);
|
||||||
await loadingTask.destroy();
|
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 () {
|
describe("Multiple `getDocument` instances", function () {
|
||||||
|
|||||||
@ -258,7 +258,7 @@ describe("struct tree", function () {
|
|||||||
await loadingTask.destroy();
|
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 filename = "bug1937438_from_word.pdf";
|
||||||
const params = buildGetDocumentParams(filename);
|
const params = buildGetDocumentParams(filename);
|
||||||
const loadingTask = getDocument(params);
|
const loadingTask = getDocument(params);
|
||||||
@ -300,6 +300,34 @@ describe("struct tree", function () {
|
|||||||
},
|
},
|
||||||
struct
|
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();
|
await loadingTask.destroy();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user