Skip to content

Commit

Permalink
Merge pull request #12539 from Snuffleupagus/TestReporter-import
Browse files Browse the repository at this point in the history
Use standard `import` statements more when running the unit-tests
  • Loading branch information
timvandermeij authored Oct 27, 2020
2 parents 6fae381 + d8da6af commit 08b00c1
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 21 deletions.
1 change: 0 additions & 1 deletion test/font/font_test.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

<script src="../../node_modules/jasmine-core/lib/jasmine-core/jasmine.js"></script>
<script src="../../node_modules/jasmine-core/lib/jasmine-core/jasmine-html.js"></script>
<script src="../unit/testreporter.js"></script>

<script defer src="../../node_modules/es-module-shims/dist/es-module-shims.js"></script>
<script type="importmap-shim">
Expand Down
4 changes: 3 additions & 1 deletion test/font/jasmine-boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/* globals jasmineRequire, TestReporter */
/* globals jasmineRequire */

// Modified jasmine's boot.js file to load PDF.js libraries async.

"use strict";

import { TestReporter } from "../unit/testreporter.js";

async function initializePDFJS(callback) {
await Promise.all(
[
Expand Down
3 changes: 3 additions & 0 deletions test/unit/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
],

"rules": {
// Plugins
"import/no-unresolved": ["error", { "ignore": ["pdfjs/"] }],

// ECMAScript 6
"no-var": "error",
},
Expand Down
23 changes: 9 additions & 14 deletions test/unit/jasmine-boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,22 @@
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/* globals jasmineRequire, TestReporter */
/* globals jasmineRequire */

// Modified jasmine's boot.js file to load PDF.js libraries async.

"use strict";

import { GlobalWorkerOptions } from "pdfjs/display/worker_options.js";
import { isNodeJS } from "pdfjs/shared/is_node.js";
import { PDFFetchStream } from "pdfjs/display/fetch_stream.js";
import { PDFNetworkStream } from "pdfjs/display/network.js";
import { setPDFNetworkStreamFactory } from "pdfjs/display/api.js";
import { TestReporter } from "./testreporter.js";

async function initializePDFJS(callback) {
const modules = await Promise.all(
await Promise.all(
[
"pdfjs/display/api.js",
"pdfjs/display/worker_options.js",
"pdfjs/display/network.js",
"pdfjs/display/fetch_stream.js",
"pdfjs/shared/is_node.js",
"pdfjs-test/unit/annotation_spec.js",
"pdfjs-test/unit/annotation_storage_spec.js",
"pdfjs-test/unit/api_spec.js",
Expand Down Expand Up @@ -87,13 +89,6 @@ async function initializePDFJS(callback) {
return import(moduleName);
})
);
const [
{ setPDFNetworkStreamFactory },
{ GlobalWorkerOptions },
{ PDFNetworkStream },
{ PDFFetchStream },
{ isNodeJS },
] = modules;

if (isNodeJS) {
throw new Error(
Expand Down
5 changes: 2 additions & 3 deletions test/unit/testreporter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
"use strict";

// eslint-disable-next-line no-unused-vars
const TestReporter = function (browser) {
function send(action, json, cb) {
const r = new XMLHttpRequest();
Expand Down Expand Up @@ -91,3 +88,5 @@ const TestReporter = function (browser) {
setTimeout(sendQuitRequest, 500);
};
};

export { TestReporter };
1 change: 0 additions & 1 deletion test/unit/unit_test.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

<script src="../../node_modules/jasmine-core/lib/jasmine-core/jasmine.js"></script>
<script src="../../node_modules/jasmine-core/lib/jasmine-core/jasmine-html.js"></script>
<script src="testreporter.js"></script>

<script defer src="../../node_modules/es-module-shims/dist/es-module-shims.js"></script>
<script type="importmap-shim">
Expand Down
2 changes: 1 addition & 1 deletion test/unit/util_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ describe("util", function () {
});

describe("escapeString", function () {
it("should escape (, ), \n, \r and \\", function () {
it("should escape (, ), \\n, \\r, and \\", function () {
expect(escapeString("((a\\a))\n(b(b\\b)\rb)")).toEqual(
"\\(\\(a\\\\a\\)\\)\\n\\(b\\(b\\\\b\\)\\rb\\)"
);
Expand Down

0 comments on commit 08b00c1

Please sign in to comment.