Merge pull request #11095 from timvandermeij/api-attachments-unit-test

Include a reduced, non-linked PDF file for the attachments API unit test
This commit is contained in:
Tim van der Meij 2019-08-25 15:22:51 +02:00 committed by GitHub
commit d64b49831d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 8 deletions

View File

@ -250,6 +250,7 @@
!bug1175962.pdf !bug1175962.pdf
!bug1020226.pdf !bug1020226.pdf
!issue9534_reduced.pdf !issue9534_reduced.pdf
!attachment.pdf
!basicapi.pdf !basicapi.pdf
!issue2884_reduced.pdf !issue2884_reduced.pdf
!mixedfonts.pdf !mixedfonts.pdf

BIN
test/pdfs/attachment.pdf Normal file

Binary file not shown.

View File

@ -692,18 +692,15 @@ describe('api', function() {
}).catch(done.fail); }).catch(done.fail);
}); });
it('gets attachments', function(done) { it('gets attachments', function(done) {
if (isNodeJS()) { // The PDF file used is a linked test-case. var loadingTask = getDocument(buildGetDocumentParams('attachment.pdf'));
pending('TODO: Use a non-linked test-case.');
}
var loadingTask = getDocument(buildGetDocumentParams('bug766138.pdf'));
var promise = loadingTask.promise.then(function (pdfDoc) { var promise = loadingTask.promise.then(function (pdfDoc) {
return pdfDoc.getAttachments(); return pdfDoc.getAttachments();
}); });
promise.then(function (data) { promise.then(function (data) {
var attachment = data['Press Quality.joboptions']; var attachment = data['foo.txt'];
expect(attachment.filename).toEqual('Press Quality.joboptions'); expect(attachment.filename).toEqual('foo.txt');
expect(attachment.content instanceof Uint8Array).toBeTruthy(); expect(attachment.content).toEqual(
expect(attachment.content.length).toEqual(30098); new Uint8Array([98, 97, 114, 32, 98, 97, 122, 32, 10]));
loadingTask.destroy().then(done); loadingTask.destroy().then(done);
}).catch(done.fail); }).catch(done.fail);