Skip to content

Commit

Permalink
HTML Reporter: Add basic ES6 Map fallback for fuzzysort.js
Browse files Browse the repository at this point in the history
Follows-up 474a708, which added fuzzysort.js, which has an
undocumented dependency on ES6 Map (whilst publishing its code
in UMD/ES5-syntax).

Restore IE 10 compat by adding a simple inline fallback
(it only needs to work with strings).

Also:
* Restore ESLint settings on test/main/ to explicitly disable
  es6. This used to be the default (we enable es6:true on /src/
  and /test/cli), but now that ESLint enables it by default we need
  to disable it to flag its use.
* Fix the handful of syntaxes that were introduced and caused
  tests to fail as a result.

Ref #1440.
  • Loading branch information
Krinkle committed Aug 16, 2020
1 parent 077e789 commit 1a80f94
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 7 deletions.
17 changes: 17 additions & 0 deletions src/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,20 @@ export const localSessionStorage = ( function() {
return undefined;
}
}() );

// Support IE 9-10: Fallback for fuzzysort.js used by /reporter/html.js
if ( !global.Map ) {
global.Map = function StringMap() {
var store = Object.create( null );
this.get = function( strKey ) {
return store[ strKey ];
};
this.set = function( strKey, val ) {
store[ strKey ] = val;
return this;
};
this.clear = function() {
store = Object.create( null );
};
};
}
4 changes: 3 additions & 1 deletion test/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"extends": [ "plugin:qunit/two" ],
"env": {
"browser": true
"browser": true,
"es6": false
},
"plugins": [
"html",
Expand All @@ -12,6 +13,7 @@
},
"globals": {
"QUnit": false,
"Promise": false,
"console": false
},
"rules": {
Expand Down
3 changes: 2 additions & 1 deletion test/cli/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"ecmaVersion": 2017
},
"env": {
"node": true
"node": true,
"es6": true
}
}
2 changes: 1 addition & 1 deletion test/main/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ QUnit.test( "rejects", function( assert ) {
return this.message;
};

const rejectsReturnValue = assert.rejects(
var rejectsReturnValue = assert.rejects(
buildMockPromise( "my error" )
);

Expand Down
2 changes: 1 addition & 1 deletion test/main/assert/step.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ QUnit.module( "assert.verifySteps value reference", function() {
} );

QUnit.test( "steps array should not be reset in logging function", function( assert ) {
const result = loggedAssertions[ "verification-assertion" ].actual;
var result = loggedAssertions[ "verification-assertion" ].actual;
assert.deepEqual( result, [ "step one", "step two" ] );
} );

Expand Down
2 changes: 2 additions & 0 deletions test/main/utilities.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* globals Map, Set, Symbol */

QUnit.module( "QUnit.objectType" );

function Foo( ) { }
Expand Down
2 changes: 1 addition & 1 deletion test/only.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
QUnit.module( "QUnit.only", function( hooks ) {
let testsRun = 0;
var testsRun = 0;

hooks.after( function( assert ) {
assert.strictEqual( testsRun, 2 );
Expand Down
2 changes: 1 addition & 1 deletion test/reporter-html/unhandled-rejection.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if ( HAS_UNHANDLED_REJECTION_HANDLER ) {
} );

QUnit.test( "test passes just fine, but has a rejected promise", function( assert ) {
const done = assert.async();
var done = assert.async();

Promise.resolve().then( function() {
throw new Error( "Error thrown in non-returned promise!" );
Expand Down
2 changes: 1 addition & 1 deletion test/reporter-html/window-onerror.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ QUnit.module( "window.onerror (no preexisting handler)", function( hooks ) {
QUnit.test( "Should extract stacktrace if it is available", function( assert ) {
assert.expect( 1 );

const errorObj = {
var errorObj = {
stack: "dummy.js:1 top()\ndummy.js:2 middle()\ndummy.js:3 bottom()"
};

Expand Down
1 change: 1 addition & 0 deletions test/webWorker-worker.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* global importScripts */
/* eslint-env es6 */
importScripts(
"../dist/qunit.js",
"main/test.js",
Expand Down

0 comments on commit 1a80f94

Please sign in to comment.