Merge pull request #12539 from Snuffleupagus/TestReporter-import

Use standard `import` statements more when running the unit-tests
This commit is contained in:
Tim van der Meij 2020-10-27 22:26:37 +01:00 committed by GitHub
commit 08b00c13a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 18 additions and 21 deletions

View File

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

View File

@ -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(
[

View File

@ -4,6 +4,9 @@
],
"rules": {
// Plugins
"import/no-unresolved": ["error", { "ignore": ["pdfjs/"] }],
// ECMAScript 6
"no-var": "error",
},

View File

@ -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",
@ -87,13 +89,6 @@ async function initializePDFJS(callback) {
return import(moduleName);
})
);
const [
{ setPDFNetworkStreamFactory },
{ GlobalWorkerOptions },
{ PDFNetworkStream },
{ PDFFetchStream },
{ isNodeJS },
] = modules;
if (isNodeJS) {
throw new Error(

View File

@ -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();
@ -91,3 +88,5 @@ const TestReporter = function (browser) {
setTimeout(sendQuitRequest, 500);
};
};
export { TestReporter };

View File

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

View File

@ -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\\)"
);