[Pkg-javascript-commits] [pdf.js] 313/414: Faster unit-tests by using `beforeAll`/`afterAll` in api_spec.js
David Prévot
taffit at moszumanska.debian.org
Tue Jun 28 17:12:34 UTC 2016
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository pdf.js.
commit 7163e1eff324daea6aa23f6decbffd4637b5d849
Author: Jonas Jenwald <jonas.jenwald at gmail.com>
Date: Wed Mar 30 15:24:57 2016 +0200
Faster unit-tests by using `beforeAll`/`afterAll` in api_spec.js
In the API unit-tests, we're currently loading the `basicapi.pdf` before every sub-test in `PDFDocument` and `Page`, which slows down the unit-tests quite a bit.
Locally this patch reduces the run time for `gulp unittest` by at least 40% for me.
---
test/unit/api_spec.js | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/test/unit/api_spec.js b/test/unit/api_spec.js
index 0e77220..42a657d 100644
--- a/test/unit/api_spec.js
+++ b/test/unit/api_spec.js
@@ -1,6 +1,6 @@
-/* globals PDFJS, expect, it, describe, Promise, combineUrl,
+/* globals PDFJS, expect, it, describe, Promise, combineUrl, beforeAll,
InvalidPDFException, MissingPDFException, StreamType, FontType,
- PDFDocumentProxy, PasswordException, PasswordResponses,
+ PDFDocumentProxy, PasswordException, PasswordResponses, afterAll,
PDFPageProxy, createPromiseCapability, beforeEach, afterEach */
'use strict';
@@ -310,7 +310,7 @@ describe('api', function() {
var loadingTask;
var doc;
- beforeEach(function(done) {
+ beforeAll(function(done) {
loadingTask = PDFJS.getDocument(basicApiUrl);
loadingTask.promise.then(function(data) {
doc = data;
@@ -318,7 +318,7 @@ describe('api', function() {
});
});
- afterEach(function() {
+ afterAll(function() {
loadingTask.destroy();
});
@@ -680,7 +680,7 @@ describe('api', function() {
var loadingTask;
var pdfDocument, page;
- beforeEach(function(done) {
+ beforeAll(function(done) {
loadingTask = PDFJS.getDocument(basicApiUrl);
loadingTask.promise.then(function(doc) {
pdfDocument = doc;
@@ -693,7 +693,7 @@ describe('api', function() {
});
});
- afterEach(function() {
+ afterAll(function() {
loadingTask.destroy();
});
--
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