[Pkg-javascript-commits] [pdf.js] 17/157: Further improvements of the getStats and getDownloadInfo unit tests
David Prévot
taffit at moszumanska.debian.org
Tue Aug 11 06:46:27 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository pdf.js.
commit 38955d491fc1368737c075f99459af3655b29b32
Author: Jonas Jenwald <jonas.jenwald at gmail.com>
Date: Thu Jun 25 22:51:17 2015 +0200
Further improvements of the getStats and getDownloadInfo unit tests
The patch adds a test to ensure that `getStats` returns the expected result after the page has been parsed, and cleans up the existing test a bit.
Also, since I'm touching the file anyway, I'm making a small adjustment of the `getDownloadInfo` test. (I have no idea why I didn't just write it like this initially.)
---
test/unit/api_spec.js | 26 +++++++++++++++++++++-----
1 file changed, 21 insertions(+), 5 deletions(-)
diff --git a/test/unit/api_spec.js b/test/unit/api_spec.js
index 2d5d17b..5064e3f 100644
--- a/test/unit/api_spec.js
+++ b/test/unit/api_spec.js
@@ -1,7 +1,7 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
/* globals PDFJS, expect, it, describe, Promise, combineUrl, waitsFor,
- isArray, MissingPDFException */
+ MissingPDFException, StreamType, FontType */
'use strict';
@@ -167,17 +167,16 @@ describe('api', function() {
expect(data.length).toEqual(basicApiFileLength);
});
});
- it('gets filesize in bytes', function() {
+ it('gets download info', function() {
var promise = doc.getDownloadInfo();
waitsForPromiseResolved(promise, function (data) {
- expect(data.length).toEqual(basicApiFileLength);
+ expect(data).toEqual({ length: basicApiFileLength });
});
});
it('gets stats', function() {
var promise = doc.getStats();
waitsForPromiseResolved(promise, function (stats) {
- expect(isArray(stats.streamTypes)).toEqual(true);
- expect(isArray(stats.fontTypes)).toEqual(true);
+ expect(stats).toEqual({ streamTypes: [], fontTypes: [] });
});
});
});
@@ -186,10 +185,12 @@ describe('api', function() {
var promise = new Promise(function (resolve) {
resolvePromise = resolve;
});
+ var pdfDocument;
PDFJS.getDocument(basicApiUrl).then(function(doc) {
doc.getPage(1).then(function(data) {
resolvePromise(data);
});
+ pdfDocument = doc;
});
var page;
waitsForPromiseResolved(promise, function(data) {
@@ -238,5 +239,20 @@ describe('api', function() {
expect(oplist.lastChunk).toEqual(true);
});
});
+ it('gets stats after parsing page', function () {
+ var promise = page.getOperatorList().then(function () {
+ return pdfDocument.getStats();
+ });
+ var expectedStreamTypes = [];
+ expectedStreamTypes[StreamType.FLATE] = true;
+ var expectedFontTypes = [];
+ expectedFontTypes[FontType.TYPE1] = true;
+ expectedFontTypes[FontType.CIDFONTTYPE2] = true;
+
+ waitsForPromiseResolved(promise, function (stats) {
+ expect(stats).toEqual({ streamTypes: expectedStreamTypes,
+ fontTypes: expectedFontTypes });
+ });
+ });
});
});
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git
More information about the Pkg-javascript-commits
mailing list