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:
commit
ee665fc053
@ -52,8 +52,9 @@ describe("document", function () {
|
|||||||
};
|
};
|
||||||
const stream = new StringStream("Dummy_PDF_data");
|
const stream = new StringStream("Dummy_PDF_data");
|
||||||
|
|
||||||
function getDocument(acroForm) {
|
function getDocument(acroForm, xref = new XRefMock()) {
|
||||||
const pdfDocument = new PDFDocument(pdfManager, stream);
|
const pdfDocument = new PDFDocument(pdfManager, stream);
|
||||||
|
pdfDocument.xref = xref;
|
||||||
pdfDocument.catalog = { acroForm };
|
pdfDocument.catalog = { acroForm };
|
||||||
return pdfDocument;
|
return pdfDocument;
|
||||||
}
|
}
|
||||||
@ -144,18 +145,18 @@ describe("document", function () {
|
|||||||
kidsDict.set("Kids", [annotationRef]);
|
kidsDict.set("Kids", [annotationRef]);
|
||||||
const kidsRef = Ref.get(10, 0);
|
const kidsRef = Ref.get(10, 0);
|
||||||
|
|
||||||
pdfDocument.xref = new XRefMock([
|
const xref = new XRefMock([
|
||||||
{ ref: annotationRef, data: annotationDict },
|
{ ref: annotationRef, data: annotationDict },
|
||||||
{ ref: kidsRef, data: kidsDict },
|
{ ref: kidsRef, data: kidsDict },
|
||||||
]);
|
]);
|
||||||
|
|
||||||
acroForm.set("Fields", [kidsRef]);
|
acroForm.set("Fields", [kidsRef]);
|
||||||
acroForm.set("SigFlags", 3);
|
acroForm.set("SigFlags", 3);
|
||||||
pdfDocument = getDocument(acroForm);
|
pdfDocument = getDocument(acroForm, xref);
|
||||||
expect(pdfDocument.formInfo).toEqual({
|
expect(pdfDocument.formInfo).toEqual({
|
||||||
hasAcroForm: false,
|
hasAcroForm: false,
|
||||||
hasXfa: false,
|
hasXfa: false,
|
||||||
fields: null,
|
fields: [kidsRef],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -93,8 +93,8 @@ class XRefMock {
|
|||||||
return this._map[ref.toString()];
|
return this._map[ref.toString()];
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchAsync(ref) {
|
async fetchAsync(ref) {
|
||||||
return Promise.resolve(this.fetch(ref));
|
return this.fetch(ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchIfRef(obj) {
|
fetchIfRef(obj) {
|
||||||
@ -104,8 +104,8 @@ class XRefMock {
|
|||||||
return this.fetch(obj);
|
return this.fetch(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchIfRefAsync(obj) {
|
async fetchIfRefAsync(obj) {
|
||||||
return Promise.resolve(this.fetchIfRef(obj));
|
return this.fetchIfRef(obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user