Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert the files in the /test/unit folder to ES6 modules #8298

Merged
merged 1 commit into from
Apr 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 11 additions & 37 deletions test/unit/annotation_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,42 +12,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';

(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define('pdfjs-test/unit/annotation_spec', ['exports',
'pdfjs/core/primitives', 'pdfjs/core/annotation', 'pdfjs/core/stream',
'pdfjs/core/parser', 'pdfjs/shared/util'], factory);
} else if (typeof exports !== 'undefined') {
factory(exports, require('../../src/core/primitives.js'),
require('../../src/core/annotation.js'),
require('../../src/core/stream.js'), require('../../src/core/parser.js'),
require('../../src/shared/util.js'));
} else {
factory((root.pdfjsTestUnitAnnotationSpec = {}),
root.pdfjsCorePrimitives, root.pdfjsCoreAnnotation, root.pdfjsCoreStream,
root.pdfjsCoreParser, root.pdfjsSharedUtil);
}
}(this, function (exports, corePrimitives, coreAnnotation, coreStream,
coreParser, sharedUtil) {

var Annotation = coreAnnotation.Annotation;
var AnnotationBorderStyle = coreAnnotation.AnnotationBorderStyle;
var AnnotationFactory = coreAnnotation.AnnotationFactory;
var Lexer = coreParser.Lexer;
var Parser = coreParser.Parser;
var isRef = corePrimitives.isRef;
var Dict = corePrimitives.Dict;
var Name = corePrimitives.Name;
var Ref = corePrimitives.Ref;
var StringStream = coreStream.StringStream;
var AnnotationType = sharedUtil.AnnotationType;
var AnnotationFlag = sharedUtil.AnnotationFlag;
var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
var AnnotationFieldFlag = sharedUtil.AnnotationFieldFlag;
var stringToBytes = sharedUtil.stringToBytes;
var stringToUTF8String = sharedUtil.stringToUTF8String;

import {
Annotation, AnnotationBorderStyle, AnnotationFactory
} from '../../src/core/annotation';
import {
AnnotationBorderStyleType, AnnotationFieldFlag, AnnotationFlag,
AnnotationType, stringToBytes, stringToUTF8String
} from '../../src/shared/util';
import { Dict, isRef, Name, Ref } from '../../src/core/primitives';
import { Lexer, Parser } from '../../src/core/parser';
import { StringStream } from '../../src/core/stream';

describe('annotation', function() {
function XRefMock(array) {
Expand Down Expand Up @@ -1393,4 +1368,3 @@ describe('annotation', function() {
});
});
});
}));
42 changes: 10 additions & 32 deletions test/unit/api_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';

(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define('pdfjs-test/unit/api_spec', ['exports', 'pdfjs/shared/util',
'pdfjs/display/dom_utils', 'pdfjs/display/global', 'pdfjs/display/api'],
factory);
} else if (typeof exports !== 'undefined') {
factory(exports, require('../../src/shared/util.js'),
require('../../src/display/dom_utils.js'),
require('../../src/display/global.js'),
require('../../src/display/api.js'));
} else {
factory((root.pdfjsTestUnitApiSpec = {}), root.pdfjsSharedUtil,
root.pdfjsDisplayDOMUtils, root.pdfjsDisplayGlobal, root.pdfjsDisplayApi);
}
}(this, function (exports, sharedUtil, displayDOMUtils, displayGlobal,
displayApi) {

var PDFJS = displayGlobal.PDFJS;
var createPromiseCapability = sharedUtil.createPromiseCapability;
var DOMCanvasFactory = displayDOMUtils.DOMCanvasFactory;
var RenderingCancelledException = displayDOMUtils.RenderingCancelledException;
var PDFDocumentProxy = displayApi.PDFDocumentProxy;
var InvalidPDFException = sharedUtil.InvalidPDFException;
var MissingPDFException = sharedUtil.MissingPDFException;
var PasswordResponses = sharedUtil.PasswordResponses;
var PasswordException = sharedUtil.PasswordException;
var PDFPageProxy = displayApi.PDFPageProxy;
var StreamType = sharedUtil.StreamType;
var FontType = sharedUtil.FontType;

import {
createPromiseCapability, FontType, InvalidPDFException, MissingPDFException,
PasswordException, PasswordResponses, StreamType
} from '../../src/shared/util';
import {
DOMCanvasFactory, RenderingCancelledException
} from '../../src/display/dom_utils';
import { PDFDocumentProxy, PDFPageProxy } from '../../src/display/api';
import { PDFJS } from '../../src/display/global';

describe('api', function() {
var basicApiUrl = new URL('../pdfs/basicapi.pdf', window.location).href;
Expand Down Expand Up @@ -1210,4 +1189,3 @@ describe('api', function() {
});
});
});
}));
15 changes: 1 addition & 14 deletions test/unit/bidi_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';

(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define('pdfjs-test/unit/bidi_spec', ['exports', 'pdfjs/core/bidi'],
factory);
} else if (typeof exports !== 'undefined') {
factory(exports, require('../../src/core/bidi.js'));
} else {
factory((root.pdfjsTestUnitBidiSpec = {}), root.pdfjsCoreBidi);
}
}(this, function (exports, coreBidi) {

var bidi = coreBidi.bidi;
import { bidi } from '../../src/core/bidi';

describe('bidi', function () {
it('should mark text as RTL if more than 30% of text is RTL', function() {
Expand All @@ -47,4 +35,3 @@ describe('bidi', function () {
expect(bidiText.dir).toEqual('ltr');
});
});
}));
28 changes: 5 additions & 23 deletions test/unit/cff_parser_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';

(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define('pdfjs-test/unit/cff_parser_spec', ['exports',
'pdfjs/core/cff_parser', 'pdfjs/core/fonts',
'pdfjs/core/stream'], factory);
} else if (typeof exports !== 'undefined') {
factory(exports, require('../../src/core/cff_parser.js'),
require('../../src/core/fonts.js'),
require('../../src/core/stream.js'));
} else {
factory((root.pdfjsTestUnitCFFParserSpec = {}), root.pdfjsCoreCFFParser,
root.pdfjsCoreFonts, root.pdfjsCoreStream);
}
}(this, function (exports, coreCFFParser, coreFonts, coreStream) {

var CFFParser = coreCFFParser.CFFParser;
var CFFIndex = coreCFFParser.CFFIndex;
var CFFStrings = coreCFFParser.CFFStrings;
var CFFCompiler = coreCFFParser.CFFCompiler;
var SEAC_ANALYSIS_ENABLED = coreFonts.SEAC_ANALYSIS_ENABLED;
var Stream = coreStream.Stream;
import {
CFFCompiler, CFFIndex, CFFParser, CFFStrings
} from '../../src/core/cff_parser';
import { SEAC_ANALYSIS_ENABLED } from '../../src/core/fonts';
import { Stream } from '../../src/core/stream';

describe('CFFParser', function() {
function createWithNullProto(obj) {
Expand Down Expand Up @@ -388,4 +371,3 @@ describe('CFFCompiler', function() {

// TODO a lot more compiler tests
});
}));
36 changes: 6 additions & 30 deletions test/unit/cmap_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';

(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define('pdfjs-test/unit/cmap_spec', ['exports', 'pdfjs/core/cmap',
'pdfjs/core/primitives', 'pdfjs/core/stream', 'pdfjs/display/dom_utils',
'pdfjs/shared/util', 'pdfjs-test/unit/test_utils'], factory);
} else if (typeof exports !== 'undefined') {
factory(exports, require('../../src/core/cmap.js'),
require('../../src/core/primitives.js'),
require('../../src/core/stream.js'),
require('../../src/display/dom_utils.js'),
require('../../src/shared/util.js'), require('./test_utils.js'));
} else {
factory((root.pdfjsTestUnitCMapSpec = {}), root.pdfjsCoreCMap,
root.pdfjsCorePrimitives, root.pdfjsCoreStream,
root.pdfjsDisplayDOMUtils, root.pdfjsSharedUtil,
root.pdfjsTestUnitTestUtils);
}
}(this, function (exports, coreCMap, corePrimitives, coreStream,
displayDOMUtils, sharedUtil, testUnitTestUtils) {

var CMapFactory = coreCMap.CMapFactory;
var CMap = coreCMap.CMap;
var IdentityCMap = coreCMap.IdentityCMap;
var Name = corePrimitives.Name;
var StringStream = coreStream.StringStream;
var DOMCMapReaderFactory = displayDOMUtils.DOMCMapReaderFactory;
var isNodeJS = sharedUtil.isNodeJS;
var NodeCMapReaderFactory = testUnitTestUtils.NodeCMapReaderFactory;
import { CMap, CMapFactory, IdentityCMap } from '../../src/core/cmap';
import { DOMCMapReaderFactory } from '../../src/display/dom_utils';
import { isNodeJS } from '../../src/shared/util';
import { Name } from '../../src/core/primitives';
import { NodeCMapReaderFactory } from './test_utils';
import { StringStream } from '../../src/core/stream';

var cMapUrl = {
dom: '../../external/bcmaps/',
Expand Down Expand Up @@ -310,4 +287,3 @@ describe('cmap', function() {
});
});
});
}));
41 changes: 9 additions & 32 deletions test/unit/crypto_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';

(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define('pdfjs-test/unit/crypto_spec', ['exports', 'pdfjs/core/crypto',
'pdfjs/core/primitives', 'pdfjs/shared/util'], factory);
} else if (typeof exports !== 'undefined') {
factory(exports, require('../../src/core/crypto.js'),
require('../../src/core/primitives.js'),
require('../../src/shared/util.js'));
} else {
factory((root.pdfjsTestUnitCryptoSpec = {}), root.pdfjsCoreCrypto,
root.pdfjsCorePrimitives, root.pdfjsSharedUtil);
}
}(this, function (exports, coreCrypto, corePrimitives, sharedUtil) {

var calculateMD5 = coreCrypto.calculateMD5;
var ARCFourCipher = coreCrypto.ARCFourCipher;
var calculateSHA256 = coreCrypto.calculateSHA256;
var calculateSHA384 = coreCrypto.calculateSHA384;
var calculateSHA512 = coreCrypto.calculateSHA512;
var AES128Cipher = coreCrypto.AES128Cipher;
var AES256Cipher = coreCrypto.AES256Cipher;
var PDF17 = coreCrypto.PDF17;
var PDF20 = coreCrypto.PDF20;
var CipherTransformFactory = coreCrypto.CipherTransformFactory;
var Name = corePrimitives.Name;
var Dict = corePrimitives.Dict;
var stringToBytes = sharedUtil.stringToBytes;
var PasswordException = sharedUtil.PasswordException;
var PasswordResponses = sharedUtil.PasswordResponses;

import {
AES128Cipher, AES256Cipher, ARCFourCipher, calculateMD5, calculateSHA256,
calculateSHA384, calculateSHA512, CipherTransformFactory, PDF17, PDF20
} from '../../src/core/crypto';
import { Dict, Name } from '../../src/core/primitives';
import {
PasswordException, PasswordResponses, stringToBytes
} from '../../src/shared/util';

describe('crypto', function() {
function hex2binary(s) {
Expand Down Expand Up @@ -708,4 +686,3 @@ describe('CipherTransformFactory', function() {
});
});
});
}));
16 changes: 1 addition & 15 deletions test/unit/document_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';

(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define('pdfjs-test/unit/document_spec', ['exports', 'pdfjs/core/document'],
factory);
} else if (typeof exports !== 'undefined') {
factory(exports, require('../../src/core/document.js'));
} else {
factory((root.pdfjsTestUnitDocumentSpec = {}),
root.pdfjsCoreDocument);
}
}(this, function (exports, coreDocument) {

var Page = coreDocument.Page;
import { Page } from '../../src/core/document';

describe('document', function () {
describe('Page', function () {
Expand Down Expand Up @@ -55,4 +42,3 @@ describe('document', function () {
});
});
});
}));
23 changes: 4 additions & 19 deletions test/unit/dom_utils_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';

(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define('pdfjs-test/unit/dom_utils_spec', ['exports',
'pdfjs/display/dom_utils', 'pdfjs/display/global'], factory);
} else if (typeof exports !== 'undefined') {
factory(exports, require('../../src/display/dom_utils.js'),
require('../../src/display/global.js'));
} else {
factory((root.pdfjsTestUnitDOMUtilsSpec = {}), root.pdfjsDisplayDOMUtils,
root.pdfjsDisplayGlobal);
}
}(this, function (exports, displayDOMUtils, displayGlobal) {

var PDFJS = displayGlobal.PDFJS;
var getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl;
var LinkTarget = displayDOMUtils.LinkTarget;
var isExternalLinkTargetSet = displayDOMUtils.isExternalLinkTargetSet;
import {
getFilenameFromUrl, isExternalLinkTargetSet, LinkTarget
} from '../../src/display/dom_utils';
import { PDFJS } from '../../src/display/global';

describe('dom_utils', function() {
describe('getFilenameFromUrl', function() {
Expand Down Expand Up @@ -82,4 +68,3 @@ describe('dom_utils', function() {
});
});
});
}));
35 changes: 5 additions & 30 deletions test/unit/evaluator_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';

(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define('pdfjs-test/unit/evaluator_spec', ['exports',
'pdfjs/core/evaluator', 'pdfjs/core/primitives',
'pdfjs/core/stream', 'pdfjs/core/worker',
'pdfjs/shared/util'], factory);
} else if (typeof exports !== 'undefined') {
factory(exports, require('../../src/core/evaluator.js'),
require('../../src/core/primitives.js'),
require('../../src/core/stream.js'),
require('../../src/core/worker.js'),
require('../../src/shared/util.js'));
} else {
factory((root.pdfjsTestUnitEvaluatorSpec = {}), root.pdfjsCoreEvaluator,
root.pdfjsCorePrimitives, root.pdfjsCoreStream,
root.pdfjsCoreWorker, root.pdfjsSharedUtil);
}
}(this, function (exports, coreEvaluator, corePrimitives, coreStream,
coreWorker, sharedUtil) {

var OperatorList = coreEvaluator.OperatorList;
var PartialEvaluator = coreEvaluator.PartialEvaluator;
var Dict = corePrimitives.Dict;
var Name = corePrimitives.Name;
var Stream = coreStream.Stream;
var StringStream = coreStream.StringStream;
var WorkerTask = coreWorker.WorkerTask;
var OPS = sharedUtil.OPS;
import { Dict, Name } from '../../src/core/primitives';
import { OperatorList, PartialEvaluator } from '../../src/core/evaluator';
import { Stream, StringStream } from '../../src/core/stream';
import { OPS } from '../../src/shared/util';
import { WorkerTask } from '../../src/core/worker';

describe('evaluator', function() {
function XrefMock(queue) {
Expand Down Expand Up @@ -361,4 +337,3 @@ describe('evaluator', function() {
});
});
});
}));
Loading