Add a getAttachments unit-test for a PDF file that actually contains attachments

This commit is contained in:
Jonas Jenwald 2016-07-02 13:13:30 +02:00
parent f082407ab4
commit 72c1df726e

View File

@ -497,7 +497,8 @@ describe('api', function() {
done.fail(reason);
});
});
it('gets attachments', function(done) {
it('gets non-existent attachments', function(done) {
var promise = doc.getAttachments();
promise.then(function (data) {
expect(data).toEqual(null);
@ -506,6 +507,25 @@ describe('api', function() {
done.fail(reason);
});
});
it('gets attachments', function(done) {
var url = new URL('../pdfs/bug766138.pdf', window.location).href;
var loadingTask = PDFJS.getDocument(url);
var promise = loadingTask.promise.then(function (pdfDoc) {
return pdfDoc.getAttachments();
});
promise.then(function (data) {
var attachment = data['Press Quality.joboptions'];
expect(attachment.filename).toEqual('Press Quality.joboptions');
expect(attachment.content instanceof Uint8Array).toBeTruthy();
expect(attachment.content.length).toEqual(30098);
loadingTask.destroy();
done();
}).catch(function (reason) {
done.fail(reason);
});
});
it('gets javascript', function(done) {
var promise = doc.getJavaScript();
promise.then(function (data) {