Merge pull request #12479 from Snuffleupagus/fix-formInfo-test

Fix the "should get form info when AcroForm is present" unit-test
This commit is contained in:
Tim van der Meij 2020-10-15 22:19:05 +02:00 committed by GitHub
commit ee665fc053
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 8 deletions

View File

@ -52,8 +52,9 @@ describe("document", function () {
};
const stream = new StringStream("Dummy_PDF_data");
function getDocument(acroForm) {
function getDocument(acroForm, xref = new XRefMock()) {
const pdfDocument = new PDFDocument(pdfManager, stream);
pdfDocument.xref = xref;
pdfDocument.catalog = { acroForm };
return pdfDocument;
}
@ -144,18 +145,18 @@ describe("document", function () {
kidsDict.set("Kids", [annotationRef]);
const kidsRef = Ref.get(10, 0);
pdfDocument.xref = new XRefMock([
const xref = new XRefMock([
{ ref: annotationRef, data: annotationDict },
{ ref: kidsRef, data: kidsDict },
]);
acroForm.set("Fields", [kidsRef]);
acroForm.set("SigFlags", 3);
pdfDocument = getDocument(acroForm);
pdfDocument = getDocument(acroForm, xref);
expect(pdfDocument.formInfo).toEqual({
hasAcroForm: false,
hasXfa: false,
fields: null,
fields: [kidsRef],
});
});
});

View File

@ -93,8 +93,8 @@ class XRefMock {
return this._map[ref.toString()];
}
fetchAsync(ref) {
return Promise.resolve(this.fetch(ref));
async fetchAsync(ref) {
return this.fetch(ref);
}
fetchIfRef(obj) {
@ -104,8 +104,8 @@ class XRefMock {
return this.fetch(obj);
}
fetchIfRefAsync(obj) {
return Promise.resolve(this.fetchIfRef(obj));
async fetchIfRefAsync(obj) {
return this.fetchIfRef(obj);
}
}