[Pkg-javascript-commits] [pdf.js] 60/174: Add unit-tests for `isExternalLinkTargetSet`

David Prévot taffit at moszumanska.debian.org
Thu Nov 19 18:45:12 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 39b962e3b0bf22c65f239c7e82fff13be0494174
Author: Jonas Jenwald <jonas.jenwald at gmail.com>
Date:   Wed Sep 30 12:59:50 2015 +0200

    Add unit-tests for `isExternalLinkTargetSet`
---
 test/unit/util_spec.js | 32 ++++++++++++++++++++++++++++++--
 1 file changed, 30 insertions(+), 2 deletions(-)

diff --git a/test/unit/util_spec.js b/test/unit/util_spec.js
index 2973ec1..5c4b838 100644
--- a/test/unit/util_spec.js
+++ b/test/unit/util_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 expect, it, describe, combineUrl, Dict, isDict, Name,
-           stringToPDFString */
+/* globals expect, it, describe, combineUrl, Dict, isDict, Name, PDFJS,
+           stringToPDFString, isExternalLinkTargetSet, LinkTarget */
 
 'use strict';
 
@@ -99,4 +99,32 @@ describe('util', function() {
       expect(stringToPDFString(str2)).toEqual('');
     });
   });
+
+  describe('isExternalLinkTargetSet', function() {
+    // Save the current state, to avoid interfering with other tests.
+    var previousExternalLinkTarget = PDFJS.externalLinkTarget;
+
+    it('handles the predefined LinkTargets', function() {
+      for (var key in LinkTarget) {
+        var linkTarget = LinkTarget[key];
+        PDFJS.externalLinkTarget = linkTarget;
+
+        expect(isExternalLinkTargetSet()).toEqual(!!linkTarget);
+      }
+    });
+
+    it('handles incorrect LinkTargets', function() {
+      var targets = [true, '', false, -1, '_blank', null];
+
+      for (var i = 0, ii = targets.length; i < ii; i++) {
+        var linkTarget = targets[i];
+        PDFJS.externalLinkTarget = linkTarget;
+
+        expect(isExternalLinkTargetSet()).toEqual(false);
+      }
+    });
+
+    // Reset the state.
+    PDFJS.externalLinkTarget = previousExternalLinkTarget;
+  });
 });

-- 
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