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

Use standard import statements more when running the unit-tests #12539

Merged
merged 3 commits into from
Oct 27, 2020
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
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