From 6680fa9e6dbbda49b7c57dcc3890a366d5a52b6d Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Wed, 31 Jul 2024 18:54:00 +0100 Subject: [PATCH] Build: Enable operator-linebreak "before" ESLint rule --- .eslintrc.base.js | 1 + bin/qunit.js | 21 +- build/prep-release.js | 3 +- build/tasks/test-on-node.js | 8 +- src/cli/run.js | 18 +- src/core/assert.js | 40 ++-- src/core/config.js | 4 +- src/core/diff.js | 129 +++++++------ src/core/dump.js | 20 +- src/core/equiv.js | 24 +-- src/core/globals.js | 12 +- src/core/reporters/HtmlReporter.js | 157 +++++++-------- src/core/reporters/PerfReporter.js | 8 +- src/core/reporters/TapReporter.js | 12 +- src/core/test.js | 87 +++++---- src/core/urlparams.js | 4 +- src/core/utilities.js | 4 +- test/main/HtmlReporter.js | 54 +++--- test/main/TapReporter.js | 298 ++++++++++++++--------------- test/main/assert-es6.js | 6 +- test/main/diff.js | 64 +++---- test/main/test.js | 6 +- test/reporter-urlparams.js | 6 +- 23 files changed, 502 insertions(+), 484 deletions(-) diff --git a/.eslintrc.base.js b/.eslintrc.base.js index 9ab8f815c..9cd689097 100644 --- a/.eslintrc.base.js +++ b/.eslintrc.base.js @@ -19,6 +19,7 @@ const config = Object.assign(standard, { 'prefer-const': 'off', 'prefer-promise-reject-errors': 'off', // extra + 'operator-linebreak': ['error', 'before', { overrides: { '=': 'after', '+=': 'after' } }], eqeqeq: ['error'], 'no-unused-vars': ['error', { args: 'all', argsIgnorePattern: '^_' }] }) diff --git a/bin/qunit.js b/bin/qunit.js index c34a880d6..d7ba593fa 100755 --- a/bin/qunit.js +++ b/bin/qunit.js @@ -26,13 +26,20 @@ program .description(description) .option('-f, --filter ', 'run only matching module or test names') .option('-m, --module ', 'run only the specified module') - .option('-r, --reporter [name]', 'specify the reporter to use; ' + - 'if no match is found or no name is provided, a list of available ' + - 'reporters will be displayed') - .option('--require ', 'specify a module or script to include before running ' + - 'any tests.', collect, []) - .option('--seed [value]', 'specify a seed to re-order your tests; ' + - 'if specified without a value, a seed will be generated') + .option('-r, --reporter [name]', + 'specify the reporter to use; ' + + 'if no match is found or no name is provided, a list of available ' + + 'reporters will be displayed' + ) + .option('--require ', + 'specify a module or script to include before running any tests.', + collect, + [] + ) + .option('--seed [value]', + 'specify a seed to re-order your tests; ' + + 'if specified without a value, a seed will be generated' + ) .option('-w, --watch', 'watch files for changes and re-run the test suite') .parse(process.argv); diff --git a/build/prep-release.js b/build/prep-release.js index c5766b993..6795f4c80 100644 --- a/build/prep-release.js +++ b/build/prep-release.js @@ -104,8 +104,7 @@ const Repo = { }) .sort() .map(change => change.line) - .join('\n') + - '\n'; + .join('\n') + '\n'; const today = new Date().toISOString().slice(0, 10); const newSection = `\n${version} / ${today} diff --git a/build/tasks/test-on-node.js b/build/tasks/test-on-node.js index e98132a71..a65c302af 100644 --- a/build/tasks/test-on-node.js +++ b/build/tasks/test-on-node.js @@ -63,10 +63,10 @@ module.exports = function (grunt) { return; } testEnd.errors.forEach((assertion) => { - out += `\n\ntest: ${testEnd.fullName.join(' > ')}\n` + - `actual : ${QUnit.dump.parse(assertion.actual)}\n` + - `expected: ${QUnit.dump.parse(assertion.expected)}\n` + - `message: ${assertion.message}\n${assertion.stack || ''}`; + out += `\n\ntest: ${testEnd.fullName.join(' > ')}\n` + + `actual : ${QUnit.dump.parse(assertion.actual)}\n` + + `expected: ${QUnit.dump.parse(assertion.expected)}\n` + + `message: ${assertion.message}\n${assertion.stack || ''}`; }); }); diff --git a/src/cli/run.js b/src/cli/run.js index 9e2a2e9f9..265d87300 100644 --- a/src/cli/run.js +++ b/src/cli/run.js @@ -30,9 +30,9 @@ function onExit () { const currentTest = QUnit.config.current; if (currentTest && currentTest.pauses.size > 0) { const name = currentTest.testName; - console.error('Last test to run (' + name + ') has an async hold. ' + - 'Ensure all assert.async() callbacks are invoked and Promises resolve. ' + - 'You should also set a standard timeout via QUnit.config.testTimeout.'); + console.error('Last test to run (' + name + ') has an async hold. ' + + 'Ensure all assert.async() callbacks are invoked and Promises resolve. ' + + 'You should also set a standard timeout via QUnit.config.testTimeout.'); } } } @@ -104,10 +104,10 @@ async function run (args, options) { require(filePath); } catch (e) { if ( - (e.code === 'ERR_REQUIRE_ESM' || - (e instanceof SyntaxError && - e.message === 'Cannot use import statement outside a module')) && - (!nodeVint || nodeVint >= 72) + (e.code === 'ERR_REQUIRE_ESM' + || (e instanceof SyntaxError + && e.message === 'Cannot use import statement outside a module')) + && (!nodeVint || nodeVint >= 72) ) { // filePath is an absolute file path here (per path.resolve above). // On Windows, Node.js enforces that absolute paths via ESM use valid URLs, @@ -211,8 +211,8 @@ run.watch = function watch (args, options) { // Bare minimum delay, we have another debounce in restart(). delay: DEBOUNCE_WATCH_LENGTH, filter: (fullpath, skip) => { - if (/\/node_modules\//.test(fullpath) || - ignoreDirs.includes(path.basename(fullpath)) + if (/\/node_modules\//.test(fullpath) + || ignoreDirs.includes(path.basename(fullpath)) ) { return skip; } diff --git a/src/core/assert.js b/src/core/assert.js index 06892dc89..43f8225f6 100644 --- a/src/core/assert.js +++ b/src/core/assert.js @@ -278,8 +278,8 @@ class Assert { currentTest.assert.pushResult({ result: false, actual: block, - message: 'The value provided to `assert.throws` in ' + - '"' + currentTest.testName + '" was not a function.' + message: 'The value provided to `assert.throws` in ' + + '"' + currentTest.testName + '" was not a function.' }); return; @@ -319,8 +319,8 @@ class Assert { if (typeof then !== 'function') { currentTest.assert.pushResult({ result: false, - message: 'The value provided to `assert.rejects` in ' + - '"' + currentTest.testName + '" was not a promise.', + message: 'The value provided to `assert.rejects` in ' + + '"' + currentTest.testName + '" was not a promise.', actual: promise }); @@ -334,8 +334,8 @@ class Assert { function handleFulfillment () { currentTest.assert.pushResult({ result: false, - message: 'The promise returned by the `assert.rejects` callback in ' + - '"' + currentTest.testName + '" did not reject.', + message: 'The promise returned by the `assert.rejects` callback in ' + + '"' + currentTest.testName + '" did not reject.', actual: promise }); @@ -371,23 +371,21 @@ function validateExpectedExceptionArgs (expected, message, assertionMethod) { return [expected, message]; } else { throw new Error( - 'assert.' + assertionMethod + - ' does not accept a string value for the expected argument.\n' + - 'Use a non-string object value (e.g. RegExp or validator function) ' + - 'instead if necessary.' + 'assert.' + assertionMethod + ' does not accept a string value for the expected argument.\n' + + 'Use a non-string object value (e.g. RegExp or validator function) instead if necessary.' ); } } const valid = - !expected || // TODO: be more explicit here - expectedType === 'regexp' || - expectedType === 'function' || - expectedType === 'object'; + !expected // TODO: be more explicit here + || expectedType === 'regexp' + || expectedType === 'function' + || expectedType === 'object'; if (!valid) { - throw new Error('Invalid expected value type (' + expectedType + ') ' + - 'provided to assert.' + assertionMethod + '.'); + throw new Error('Invalid expected value type (' + expectedType + ') ' + + 'provided to assert.' + assertionMethod + '.'); } return [expected, message]; @@ -413,15 +411,15 @@ function validateException (actual, expected, message) { // Expected is a constructor, maybe an Error constructor. // Note the extra check on its prototype - this is an implicit // requirement of "instanceof", else it will throw a TypeError. - } else if (expectedType === 'function' && - expected.prototype !== undefined && actual instanceof expected) { + } else if (expectedType === 'function' + && expected.prototype !== undefined && actual instanceof expected) { result = true; // Expected is an Error object } else if (expectedType === 'object') { - result = actual instanceof expected.constructor && - actual.name === expected.name && - actual.message === expected.message; + result = actual instanceof expected.constructor + && actual.name === expected.name + && actual.message === expected.message; // Log the string form of the Error object expected = errorString(expected); diff --git a/src/core/config.js b/src/core/config.js index c85c71ce6..894ab1e86 100644 --- a/src/core/config.js +++ b/src/core/config.js @@ -84,8 +84,8 @@ const config = { { id: 'noglobals', label: 'Check for globals', - tooltip: 'Enabling this will test if any test introduces new properties on the ' + - 'global object (e.g. `window` in browsers). Stored as query string.' + tooltip: 'Enabling this will test if any test introduces new properties on the ' + + 'global object (e.g. `window` in browsers). Stored as query string.' }, { id: 'notrycatch', diff --git a/src/core/diff.js b/src/core/diff.js index a9e3bee04..a3f4b75b7 100644 --- a/src/core/diff.js +++ b/src/core/diff.js @@ -162,9 +162,9 @@ import { escapeText } from './utilities.js'; * AXCD * ABXC */ - if (lastequality && ((preIns && preDel && postIns && postDel) || - ((lastequality.length < 2) && - (preIns + preDel + postIns + postDel) === 3))) { + if (lastequality && ((preIns && preDel && postIns && postDel) + || ((lastequality.length < 2) + && (preIns + preDel + postIns + postDel) === 3))) { // Duplicate record. diffs.splice( equalities[equalitiesLength - 1], @@ -244,8 +244,7 @@ import { escapeText } from './utilities.js'; pointermid = pointermax; pointerstart = 0; while (pointermin < pointermid) { - if (text1.substring(pointerstart, pointermid) === - text2.substring(pointerstart, pointermid)) { + if (text1.substring(pointerstart, pointermid) === text2.substring(pointerstart, pointermid)) { pointermin = pointermid; pointerstart = pointermin; } else { @@ -266,9 +265,10 @@ import { escapeText } from './utilities.js'; let pointermid, pointermax, pointermin, pointerend; // Quick check for common null cases. - if (!text1 || - !text2 || - text1.charAt(text1.length - 1) !== text2.charAt(text2.length - 1)) { + if (!text1 + || !text2 + || text1.charAt(text1.length - 1) !== text2.charAt(text2.length - 1) + ) { return 0; } @@ -279,8 +279,10 @@ import { escapeText } from './utilities.js'; pointermid = pointermax; pointerend = 0; while (pointermin < pointermid) { - if (text1.substring(text1.length - pointermid, text1.length - pointerend) === - text2.substring(text2.length - pointermid, text2.length - pointerend)) { + if ( + text1.substring(text1.length - pointermid, text1.length - pointerend) + === text2.substring(text2.length - pointermid, text2.length - pointerend) + ) { pointermin = pointermid; pointerend = pointermin; } else { @@ -425,8 +427,8 @@ import { escapeText } from './utilities.js'; suffixLength = dmp.diffCommonSuffix(longtext.substring(0, i), shorttext.substring(0, j)); if (bestCommon.length < suffixLength + prefixLength) { - bestCommon = shorttext.substring(j - suffixLength, j) + - shorttext.substring(j, j + prefixLength); + bestCommon = shorttext.substring(j - suffixLength, j) + + shorttext.substring(j, j + prefixLength); bestLongtextA = longtext.substring(0, i - suffixLength); bestLongtextB = longtext.substring(i + prefixLength); bestShorttextA = shorttext.substring(0, j - suffixLength); @@ -608,8 +610,10 @@ import { escapeText } from './utilities.js'; x1 = v1[k1Offset - 1] + 1; } y1 = x1 - k1; - while (x1 < text1Length && y1 < text2Length && - text1.charAt(x1) === text2.charAt(y1)) { + while ( + x1 < text1Length && y1 < text2Length + && text1.charAt(x1) === text2.charAt(y1) + ) { x1++; y1++; } @@ -642,9 +646,11 @@ import { escapeText } from './utilities.js'; x2 = v2[k2Offset - 1] + 1; } y2 = x2 - k2; - while (x2 < text1Length && y2 < text2Length && - text1.charAt(text1Length - x2 - 1) === - text2.charAt(text2Length - y2 - 1)) { + while ( + x2 < text1Length + && y2 < text2Length + && text1.charAt(text1Length - x2 - 1) === text2.charAt(text2Length - y2 - 1) + ) { x2++; y2++; } @@ -743,10 +749,10 @@ import { escapeText } from './utilities.js'; // Eliminate an equality that is smaller or equal to the edits on both // sides of it. - if (lastequality && (lastequality.length <= - Math.max(lengthInsertions1, lengthDeletions1)) && - (lastequality.length <= Math.max(lengthInsertions2, - lengthDeletions2))) { + if (lastequality + && (lastequality.length <= Math.max(lengthInsertions1, lengthDeletions1)) + && (lastequality.length <= Math.max(lengthInsertions2, lengthDeletions2)) + ) { // Duplicate record. diffs.splice( equalities[equalitiesLength - 1], @@ -791,15 +797,16 @@ import { escapeText } from './utilities.js'; // Only extract an overlap if it is as big as the edit ahead or behind it. pointer = 1; while (pointer < diffs.length) { - if (diffs[pointer - 1][0] === DIFF_DELETE && - diffs[pointer][0] === DIFF_INSERT) { + if ( + diffs[pointer - 1][0] === DIFF_DELETE + && diffs[pointer][0] === DIFF_INSERT + ) { deletion = diffs[pointer - 1][1]; insertion = diffs[pointer][1]; overlapLength1 = this.diffCommonOverlap(deletion, insertion); overlapLength2 = this.diffCommonOverlap(insertion, deletion); if (overlapLength1 >= overlapLength2) { - if (overlapLength1 >= deletion.length / 2 || - overlapLength1 >= insertion.length / 2) { + if (overlapLength1 >= deletion.length / 2 || overlapLength1 >= insertion.length / 2) { // Overlap found. Insert an equality and trim the surrounding edits. diffs.splice( pointer, @@ -812,8 +819,7 @@ import { escapeText } from './utilities.js'; pointer++; } } else { - if (overlapLength2 >= deletion.length / 2 || - overlapLength2 >= insertion.length / 2) { + if (overlapLength2 >= deletion.length / 2 || overlapLength2 >= insertion.length / 2) { // Reverse overlap found. // Insert an equality and swap and trim the surrounding edits. diffs.splice( @@ -823,11 +829,9 @@ import { escapeText } from './utilities.js'; ); diffs[pointer - 1][0] = DIFF_INSERT; - diffs[pointer - 1][1] = - insertion.substring(0, insertion.length - overlapLength2); + diffs[pointer - 1][1] = insertion.substring(0, insertion.length - overlapLength2); diffs[pointer + 1][0] = DIFF_DELETE; - diffs[pointer + 1][1] = - deletion.substring(overlapLength2); + diffs[pointer + 1][1] = deletion.substring(overlapLength2); pointer++; } } @@ -880,8 +884,10 @@ import { escapeText } from './utilities.js'; return best; } length += found; - if (found === 0 || text1.substring(textLength - length) === - text2.substring(0, length)) { + if ( + found === 0 + || text1.substring(textLength - length) === text2.substring(0, length) + ) { best = length; length++; } @@ -1005,11 +1011,12 @@ import { escapeText } from './utilities.js'; // Factor out any common prefixes. let commonlength = this.diffCommonPrefix(textInsert, textDelete); if (commonlength !== 0) { - if ((pointer - countDelete - countInsert) > 0 && - diffs[pointer - countDelete - countInsert - 1][0] === - DIFF_EQUAL) { + if ( + (pointer - countDelete - countInsert) > 0 + && diffs[pointer - countDelete - countInsert - 1][0] === DIFF_EQUAL + ) { diffs[pointer - countDelete - countInsert - 1][1] += - textInsert.substring(0, commonlength); + textInsert.substring(0, commonlength); } else { diffs.splice(0, 0, [DIFF_EQUAL, textInsert.substring(0, commonlength) @@ -1023,22 +1030,25 @@ import { escapeText } from './utilities.js'; // Factor out any common suffixies. commonlength = this.diffCommonSuffix(textInsert, textDelete); if (commonlength !== 0) { - diffs[pointer][1] = textInsert.substring(textInsert.length - - commonlength) + diffs[pointer][1]; - textInsert = textInsert.substring(0, textInsert.length - - commonlength); - textDelete = textDelete.substring(0, textDelete.length - - commonlength); + diffs[pointer][1] = textInsert.substring(textInsert.length - commonlength) + diffs[pointer][1]; + textInsert = textInsert.substring(0, textInsert.length - commonlength); + textDelete = textDelete.substring(0, textDelete.length - commonlength); } } // Delete the offending records and add the merged ones. if (countDelete === 0) { - diffs.splice(pointer - countInsert, - countDelete + countInsert, [DIFF_INSERT, textInsert]); + diffs.splice( + pointer - countInsert, + countDelete + countInsert, + [DIFF_INSERT, textInsert] + ); } else if (countInsert === 0) { - diffs.splice(pointer - countDelete, - countDelete + countInsert, [DIFF_DELETE, textDelete]); + diffs.splice( + pointer - countDelete, + countDelete + countInsert, + [DIFF_DELETE, textDelete] + ); } else { diffs.splice( pointer - countDelete - countInsert, @@ -1046,8 +1056,10 @@ import { escapeText } from './utilities.js'; [DIFF_DELETE, textDelete], [DIFF_INSERT, textInsert] ); } - pointer = pointer - countDelete - countInsert + - (countDelete ? 1 : 0) + (countInsert ? 1 : 0) + 1; + pointer = pointer - countDelete - countInsert + + (countDelete ? 1 : 0) + + (countInsert ? 1 : 0) + + 1; } else if (pointer !== 0 && diffs[pointer - 1][0] === DIFF_EQUAL) { // Merge this equality with the previous one. diffs[pointer - 1][1] += diffs[pointer][1]; @@ -1074,8 +1086,10 @@ import { escapeText } from './utilities.js'; // Intentionally ignore the first and last element (don't need checking). while (pointer < diffs.length - 1) { - if (diffs[pointer - 1][0] === DIFF_EQUAL && - diffs[pointer + 1][0] === DIFF_EQUAL) { + if ( + diffs[pointer - 1][0] === DIFF_EQUAL + && diffs[pointer + 1][0] === DIFF_EQUAL + ) { const diffPointer = diffs[pointer][1]; const position = diffPointer.substring( diffPointer.length - diffs[pointer - 1][1].length @@ -1084,20 +1098,15 @@ import { escapeText } from './utilities.js'; // This is a single edit surrounded by equalities. if (position === diffs[pointer - 1][1]) { // Shift the edit over the previous equality. - diffs[pointer][1] = diffs[pointer - 1][1] + - diffs[pointer][1].substring(0, diffs[pointer][1].length - - diffs[pointer - 1][1].length); - diffs[pointer + 1][1] = - diffs[pointer - 1][1] + diffs[pointer + 1][1]; + diffs[pointer][1] = diffs[pointer - 1][1] + diffs[pointer][1].substring(0, diffs[pointer][1].length - diffs[pointer - 1][1].length); + diffs[pointer + 1][1] = diffs[pointer - 1][1] + diffs[pointer + 1][1]; diffs.splice(pointer - 1, 1); changes = true; - } else if (diffPointer.substring(0, diffs[pointer + 1][1].length) === - diffs[pointer + 1][1]) { + } else if (diffPointer.substring(0, diffs[pointer + 1][1].length) === diffs[pointer + 1][1]) { // Shift the edit over the next equality. diffs[pointer - 1][1] += diffs[pointer + 1][1]; diffs[pointer][1] = - diffs[pointer][1].substring(diffs[pointer + 1][1].length) + - diffs[pointer + 1][1]; + diffs[pointer][1].substring(diffs[pointer + 1][1].length) + diffs[pointer + 1][1]; diffs.splice(pointer + 1, 1); changes = true; } diff --git a/src/core/dump.js b/src/core/dump.js index 76503ba32..ec54d3873 100644 --- a/src/core/dump.js +++ b/src/core/dump.js @@ -69,11 +69,11 @@ export default (function () { function isArray (obj) { return ( // Native Arrays - Array.isArray(obj) || + Array.isArray(obj) // NodeList objects - (typeof obj.length === 'number' && obj.item !== undefined && - (obj.length + || (typeof obj.length === 'number' && obj.item !== undefined + && (obj.length ? obj.item(0) === obj[0] : (obj.item(0) === null && obj[0] === undefined) ) @@ -120,9 +120,9 @@ export default (function () { return 'date'; } else if (is('function', obj)) { return 'function'; - } else if (obj.setInterval !== undefined && - obj.document !== undefined && - obj.nodeType === undefined) { + } else if (obj.setInterval !== undefined + && obj.document !== undefined + && obj.nodeType === undefined) { return 'window'; } else if (obj.nodeType === 9) { return 'document'; @@ -226,8 +226,8 @@ export default (function () { for (let i = 0; i < keys.length; i++) { const key = keys[i]; const val = map[key]; - ret.push(dump.parse(key, 'key') + ': ' + - dump.parse(val, undefined, stack)); + ret.push(dump.parse(key, 'key') + ': ' + + dump.parse(val, undefined, stack)); } dump.down(); return join('{', ret, '}'); @@ -247,8 +247,8 @@ export default (function () { // set. Those have values like undefined, null, 0, false, "" or // "inherit". if (val && val !== 'inherit') { - ret += ' ' + attrs[i].nodeName + '=' + - dump.parse(val, 'attribute'); + ret += ' ' + attrs[i].nodeName + '=' + + dump.parse(val, 'attribute'); } } } diff --git a/src/core/equiv.js b/src/core/equiv.js index 5e7d1d9cc..49a59bbd9 100644 --- a/src/core/equiv.js +++ b/src/core/equiv.js @@ -46,9 +46,9 @@ const objTypeCallbacks = { boolean: useObjectValueEquality, number (a, b) { // Handle NaN and boxed number - return a === b || - a.valueOf() === b.valueOf() || - (isNaN(a.valueOf()) && isNaN(b.valueOf())); + return a === b + || a.valueOf() === b.valueOf() + || (isNaN(a.valueOf()) && isNaN(b.valueOf())); }, // Handle boxed string string: useObjectValueEquality, @@ -60,10 +60,10 @@ const objTypeCallbacks = { }, regexp (a, b) { - return a.source === b.source && + return a.source === b.source // Include flags in the comparison - getRegExpFlags(a) === getRegExpFlags(b); + && getRegExpFlags(a) === getRegExpFlags(b); }, // identical reference only @@ -230,11 +230,11 @@ const entryTypeCallbacks = { // Skip OOP methods that look the same if ( - a.constructor !== Object && - typeof a.constructor !== 'undefined' && - typeof a[i] === 'function' && - typeof b[i] === 'function' && - a[i].toString() === b[i].toString() + a.constructor !== Object + && typeof a.constructor !== 'undefined' + && typeof a[i] === 'function' + && typeof b[i] === 'function' + && a[i].toString() === b[i].toString() ) { continue; } @@ -263,8 +263,8 @@ function typeEquiv (a, b) { if (aType !== bType) { // Support comparing primitive to boxed primitives // Try again after possibly unwrapping one - return (aType === 'object' && BOXABLE_TYPES.has(objectType(a)) ? a.valueOf() : a) === - (bType === 'object' && BOXABLE_TYPES.has(objectType(b)) ? b.valueOf() : b); + return (aType === 'object' && BOXABLE_TYPES.has(objectType(a)) ? a.valueOf() : a) + === (bType === 'object' && BOXABLE_TYPES.has(objectType(b)) ? b.valueOf() : b); } return entryTypeCallbacks[aType](a, b); diff --git a/src/core/globals.js b/src/core/globals.js index c06617456..be1b24bba 100644 --- a/src/core/globals.js +++ b/src/core/globals.js @@ -68,10 +68,10 @@ export const sessionStorage = (function () { // Support: Safari 7; Map is undefined // Support: iOS 8; `new Map(iterable)` is not supported // Support: IE 11; Map#keys is undefined -export const StringMap = typeof g.Map === 'function' && - typeof g.Map.prototype.keys === 'function' && - typeof g.Symbol === 'function' && - typeof g.Symbol.iterator === 'symbol' +export const StringMap = typeof g.Map === 'function' + && typeof g.Map.prototype.keys === 'function' + && typeof g.Symbol === 'function' + && typeof g.Symbol.iterator === 'symbol' ? g.Map : function StringMap (input) { let store = Object.create(null); @@ -119,8 +119,8 @@ export const StringMap = typeof g.Map === 'function' && // Basic fallback for ES6 Set // Support: IE 11, `new Set(iterable)` parameter not yet implemented // Test for Set#values() which came after Set(iterable). -export const StringSet = typeof g.Set === 'function' && - typeof g.Set.prototype.values === 'function' +export const StringSet = typeof g.Set === 'function' + && typeof g.Set.prototype.values === 'function' ? g.Set : function (input) { const set = Object.create(null); diff --git a/src/core/reporters/HtmlReporter.js b/src/core/reporters/HtmlReporter.js index fdeff09b5..337c0cbba 100644 --- a/src/core/reporters/HtmlReporter.js +++ b/src/core/reporters/HtmlReporter.js @@ -71,43 +71,43 @@ function getUrlConfigHtml (config) { let escapedTooltip = escapeText(val.tooltip); if (!val.value || typeof val.value === 'string') { - urlConfigHtml += ''; + urlConfigHtml += ''; } else { let selection = false; - urlConfigHtml += ''; } @@ -382,8 +382,8 @@ export default class HtmlReporter { options: beginDetails.modules.slice(), selectedMap: new StringMap(), isDirty: function () { - return [...dropdownData.selectedMap.keys()].sort().join(',') !== - [...initialSelected.keys()].sort().join(','); + return [...dropdownData.selectedMap.keys()].sort().join(',') + !== [...initialSelected.keys()].sort().join(','); } }; @@ -406,10 +406,10 @@ export default class HtmlReporter { initialSelected = new StringMap(dropdownData.selectedMap); function createModuleListItem (moduleId, name, checked) { - return '
  • '; + return '
  • '; } /** @@ -641,31 +641,31 @@ export default class HtmlReporter { if (!testId || testId.length <= 0) { return ''; } - return '
    Rerunning selected tests: ' + - escapeText(testId.join(', ')) + - ' Run all tests
    '; + return '
    Rerunning selected tests: ' + + escapeText(testId.join(', ')) + + ' Run all tests
    '; } appendInterface (beginDetails) { // Since QUnit 1.3, these are created automatically. this.element.setAttribute('role', 'main'); this.element.innerHTML = - '
    ' + - '

    ' + escapeText(document.title) + '

    ' + - '
    ' + escapeText('QUnit ' + version) + '; ' + escapeText(navigator.userAgent) + '
    ' + - '
    ' + - '' + - '
      '; + '
      ' + + '

      ' + escapeText(document.title) + '

      ' + + '
      ' + escapeText('QUnit ' + version) + '; ' + escapeText(navigator.userAgent) + '
      ' + + '
      ' + + '' + + '
        '; this.elementBanner = this.element.querySelector('#qunit-banner'); this.elementDisplay = this.element.querySelector('#qunit-testresult-display'); @@ -849,13 +849,13 @@ export default class HtmlReporter { } actual = dump.parse(details.actual); - message += ''; + message += '
        Expected:
        ' +
        -      escapeText(expected) +
        -      '
        '; if (actual !== expected) { - message += ''; + message += ''; let showDiff = false; let diffHtml; @@ -865,48 +865,49 @@ export default class HtmlReporter { const numDiff = (details.actual - details.expected); diffHtml = (numDiff > 0 ? '+' : '') + numDiff; } - } else if (typeof details.actual !== 'boolean' && - typeof details.expected !== 'boolean' + } else if ( + typeof details.actual !== 'boolean' + && typeof details.expected !== 'boolean' ) { diffHtml = diff(expected, actual); // don't show diff if there is zero overlap - showDiff = stripHtml(diffHtml).length !== - stripHtml(expected).length + - stripHtml(actual).length; + showDiff = stripHtml(diffHtml).length + !== stripHtml(expected).length + + stripHtml(actual).length; } if (showDiff) { - message += ''; + message += ''; } - } else if (expected.indexOf('[object Array]') !== -1 || - expected.indexOf('[object Object]') !== -1) { - message += ''; + } else if (expected.indexOf('[object Array]') !== -1 + || expected.indexOf('[object Object]') !== -1) { + message += ''; } else { - message += ''; + message += ''; } if (details.source) { - message += ''; + message += ''; } message += '
        Expected:
        '
        +        + escapeText(expected)
        +        + '
        Result:
        ' +
        -          escapeText(actual) + '
        Result:
        '
        +          + escapeText(actual) + '
        Diff:
        ' +
        -            diffHtml + '
        Diff:
        '
        +            + diffHtml + '
        Message: ' + - 'Diff suppressed as the depth of object is more than current max depth (' + - this.config.maxDepth + ').

        Hint: Use QUnit.dump.maxDepth to ' + - ' run with a higher max depth or " + - 'Rerun without max depth.

        Message: ' + + 'Diff suppressed as the depth of object is more than current max depth (' + + this.config.maxDepth + ').

        Hint: Use QUnit.dump.maxDepth to ' + + ' run with a higher max depth or " + + 'Rerun without max depth.

        Message: ' + - 'Diff suppressed as the expected and actual results have an equivalent' + - ' serialization
        Message: ' + + 'Diff suppressed as the expected and actual results have an equivalent' + + ' serialization
        Source:
        ' +
        -          escapeText(details.source) + '
        Source:
        '
        +          + escapeText(details.source) + '
        '; // This occurs when pushFailure is called and we have an extracted stack trace } else if (!details.result && details.source) { - message += '' + - '' + - '
        Source:
        ' +
        -        escapeText(details.source) + '
        '; + message += '' + + '' + + '
        Source:
        '
        +        + escapeText(details.source) + '
        '; } let assertList = testItem.getElementsByTagName('ol')[0]; @@ -1030,10 +1031,10 @@ export default class HtmlReporter { let message = escapeText(errorString(error)); message = '' + message + ''; if (error && error.stack) { - message += '' + - '' + - '
        Source:
        ' +
        -        escapeText(error.stack) + '
        '; + message += '' + + '' + + '
        Source:
        '
        +        + escapeText(error.stack) + '
        '; } const assertList = testItem.getElementsByTagName('ol')[0]; const assertLi = document.createElement('li'); diff --git a/src/core/reporters/PerfReporter.js b/src/core/reporters/PerfReporter.js index d77204f5e..9b1878eb2 100644 --- a/src/core/reporters/PerfReporter.js +++ b/src/core/reporters/PerfReporter.js @@ -6,12 +6,12 @@ import Logger from '../logger.js'; // works for Node.js as well. As this can add overhead, we should keep // this opt-in on the CLI. const nativePerf = ( - window && - typeof window.performance !== 'undefined' && + window + && typeof window.performance !== 'undefined' // eslint-disable-next-line compat/compat -- Checked - typeof window.performance.mark === 'function' && + && typeof window.performance.mark === 'function' // eslint-disable-next-line compat/compat -- Checked - typeof window.performance.measure === 'function' + && typeof window.performance.measure === 'function' ) ? window.performance : undefined; diff --git a/src/core/reporters/TapReporter.js b/src/core/reporters/TapReporter.js index 19b620345..a4fed0f69 100644 --- a/src/core/reporters/TapReporter.js +++ b/src/core/reporters/TapReporter.js @@ -82,12 +82,12 @@ function prettyYamlValue (value, indent = 4) { // Is this a complex string? if ( - value === '' || - rSpecialJson.test(value) || - rSpecialYaml.test(value[0]) || - rUntrimmed.test(value) || - rNumerical.test(value) || - rBool.test(value) + value === '' + || rSpecialJson.test(value) + || rSpecialYaml.test(value[0]) + || rUntrimmed.test(value) + || rNumerical.test(value) + || rBool.test(value) ) { if (!/\n/.test(value)) { // Complex one-line string, use JSON (quoted string) diff --git a/src/core/test.js b/src/core/test.js index d90816701..049682282 100644 --- a/src/core/test.js +++ b/src/core/test.js @@ -183,8 +183,8 @@ Test.prototype = { ? this.callback.call(this.testEnvironment, this.assert, this.data) : this.callback.call(this.testEnvironment, this.assert); } catch (e) { - this.pushFailure('Died on test #' + (this.assertions.length + 1) + ': ' + - (e.message || e) + '\n' + this.stack, extractStacktrace(e, 0)); + this.pushFailure('Died on test #' + (this.assertions.length + 1) + ': ' + + (e.message || e) + '\n' + this.stack, extractStacktrace(e, 0)); // Else next test will carry the responsibility saveGlobal(); @@ -224,8 +224,8 @@ Test.prototype = { promise = hook.call(this.testEnvironment, this.assert); } catch (error) { this.pushFailure( - 'Global ' + hookName + ' failed on ' + this.testName + - ': ' + errorString(error), + 'Global ' + hookName + ' failed on ' + this.testName + + ': ' + errorString(error), extractStacktrace(error, 0) ); return; @@ -245,9 +245,9 @@ Test.prototype = { // The 'after' hook should only execute when there are no tests left and // when the 'after' and 'finish' tasks are the only tasks left to process - if (hookName === 'after' && - !lastTestWithinModuleExecuted(hookOwner) && - (config.queue.length > 0 || config._pq.taskCount() > 2)) { + if (hookName === 'after' + && !lastTestWithinModuleExecuted(hookOwner) + && (config.queue.length > 0 || config._pq.taskCount() > 2)) { return; } @@ -265,8 +265,10 @@ Test.prototype = { try { promise = hook.call(testEnvironment, this.assert); } catch (error) { - this.pushFailure(hookName + ' failed on ' + this.testName + ': ' + - (error.message || error), extractStacktrace(error, 0)); + this.pushFailure( + hookName + ' failed on ' + this.testName + ': ' + + (error.message || error), extractStacktrace(error, 0) + ); return; } } @@ -282,8 +284,8 @@ Test.prototype = { function processGlobalhooks (test) { if ( - (handler === 'beforeEach' || handler === 'afterEach') && - config._globalHooks[handler] + (handler === 'beforeEach' || handler === 'afterEach') + && config._globalHooks[handler] ) { for (let i = 0; i < config._globalHooks[handler].length; i++) { hooks.push( @@ -330,22 +332,23 @@ Test.prototype = { if (this.steps.length) { const stepsList = this.steps.join(', '); - this.pushFailure('Expected assert.verifySteps() to be called before end of test ' + - `after using assert.step(). Unverified steps: ${stepsList}`, this.stack); + this.pushFailure(`Expected assert.verifySteps() to be called before end of test after using assert.step(). Unverified steps: ${stepsList}`, + this.stack + ); } if (config.requireExpects && this.expected === null) { - this.pushFailure('Expected number of assertions to be defined, but expect() was ' + - 'not called.', this.stack); + this.pushFailure('Expected number of assertions to be defined, but expect() was not called.', this.stack); } else if (this.expected !== null && this.stepsCount && (this.expected === (this.assertions.length + this.stepsCount))) { - this.pushFailure('Expected ' + this.expected + ' assertions, but ' + - this.assertions.length + ' were run.\nIt looks like you are upgrading from QUnit 2. Steps no longer count as separate assertions. https://qunitjs.com/api/assert/expect/', this.stack); + this.pushFailure('Expected ' + this.expected + ' assertions, but ' + this.assertions.length + ' were run.\nIt looks like you are upgrading from QUnit 2. Steps no longer count as separate assertions. https://qunitjs.com/api/assert/expect/', + this.stack + ); } else if (this.expected !== null && this.expected !== this.assertions.length) { - this.pushFailure('Expected ' + this.expected + ' assertions, but ' + - this.assertions.length + ' were run', this.stack); + this.pushFailure('Expected ' + this.expected + ' assertions, but ' + this.assertions.length + ' were run', + this.stack + ); } else if (this.expected === null && !this.assertions.length) { - this.pushFailure('Expected at least one assertion, but none were run - call ' + - 'expect(0) to accept zero assertions.', this.stack); + this.pushFailure('Expected at least one assertion, but none were run - call expect(0) to accept zero assertions.', this.stack); } const module = this.module; @@ -505,8 +508,8 @@ Test.prototype = { ]; } - const previousFailCount = config.storage && - +config.storage.getItem('qunit-test-' + this.module.name + '-' + this.testName); + const previousFailCount = config.storage + && +config.storage.getItem('qunit-test-' + this.module.name + '-' + this.testName); // Prioritize previously failed tests, detected from storage const prioritize = config.reorder && !!previousFailCount; @@ -520,9 +523,9 @@ Test.prototype = { if (this !== config.current) { const message = (resultInfo && resultInfo.message) || ''; const testName = (this && this.testName) || ''; - const error = 'Assertion occurred after test finished.\n' + - '> Test: ' + testName + '\n' + - '> Message: ' + message + '\n'; + const error = 'Assertion occurred after test finished.\n' + + '> Test: ' + testName + '\n' + + '> Message: ' + message + '\n'; throw new Error(error); } @@ -562,8 +565,8 @@ Test.prototype = { pushFailure: function (message, source) { if (!(this instanceof Test)) { - throw new Error('pushFailure() assertion outside test context, was ' + - sourceFromStacktrace(2)); + throw new Error('pushFailure() assertion outside test context, was ' + + sourceFromStacktrace(2)); } this.pushResult({ @@ -676,16 +679,16 @@ Test.prototype = { return; } if (config.current === undefined) { - throw new Error('Unexpected release of async pause after tests finished.\n' + - `> Test: ${test.testName} [async #${pauseId}]`); + throw new Error('Unexpected release of async pause after tests finished.\n' + + `> Test: ${test.testName} [async #${pauseId}]`); } if (config.current !== test) { - throw new Error('Unexpected release of async pause during a different test.\n' + - `> Test: ${test.testName} [async #${pauseId}]`); + throw new Error('Unexpected release of async pause during a different test.\n' + + `> Test: ${test.testName} [async #${pauseId}]`); } if (pause.remaining <= 0) { - throw new Error('Tried to release async pause that was already released.\n' + - `> Test: ${test.testName} [async #${pauseId}]`); + throw new Error('Tried to release async pause that was already released.\n' + + `> Test: ${test.testName} [async #${pauseId}]`); } // The `requiredCalls` parameter exists to support `assert.async(count)` @@ -744,10 +747,10 @@ Test.prototype = { promise.then(resolve); } else { const reject = function (error) { - const message = 'Promise rejected ' + - (!phase ? 'during' : phase.replace(/Each$/, '')) + - ' "' + test.testName + '": ' + - ((error && error.message) || error); + const message = 'Promise rejected ' + + (!phase ? 'during' : phase.replace(/Each$/, '')) + + ' "' + test.testName + '": ' + + ((error && error.message) || error); test.pushFailure(message, extractStacktrace(error, 0)); // Else next test will carry the responsibility @@ -776,8 +779,8 @@ Test.prototype = { function moduleChainIdMatch (testModule, selectedId) { return ( // undefined or empty array - !selectedId || !selectedId.length || - inArray(testModule.moduleId, selectedId) || ( + !selectedId || !selectedId.length + || inArray(testModule.moduleId, selectedId) || ( testModule.parentModule && moduleChainIdMatch(testModule.parentModule, selectedId) ) ); @@ -850,8 +853,8 @@ Test.prototype = { export function pushFailure () { if (!config.current) { - throw new Error('pushFailure() assertion outside test context, in ' + - sourceFromStacktrace(2)); + throw new Error('pushFailure() assertion outside test context, in ' + + sourceFromStacktrace(2)); } // Gets current test obj diff --git a/src/core/urlparams.js b/src/core/urlparams.js index 740875872..b129cc465 100644 --- a/src/core/urlparams.js +++ b/src/core/urlparams.js @@ -15,8 +15,8 @@ function getUrlParams () { const name = decodeQueryParam(param[0]); // Allow just a key to turn on a flag, e.g., test.html?noglobals - const value = param.length === 1 || - decodeQueryParam(param.slice(1).join('=')); + const value = param.length === 1 + || decodeQueryParam(param.slice(1).join('=')); if (name in urlParams) { urlParams[name] = [].concat(urlParams[name], value); } else { diff --git a/src/core/utilities.js b/src/core/utilities.js index 1ee5f1ed7..ccc137b81 100644 --- a/src/core/utilities.js +++ b/src/core/utilities.js @@ -193,7 +193,7 @@ export function escapeText (str) { export function isAsyncFunction (fn) { return ( - typeof fn === 'function' && - Object.prototype.toString.call(fn) === '[object AsyncFunction]' + typeof fn === 'function' + && Object.prototype.toString.call(fn) === '[object AsyncFunction]' ); } diff --git a/test/main/HtmlReporter.js b/test/main/HtmlReporter.js index f3d391686..0aae3d2ad 100644 --- a/test/main/HtmlReporter.js +++ b/test/main/HtmlReporter.js @@ -226,11 +226,11 @@ QUnit.test('test-output [trace]', function (assert) { var testOutput = element.querySelector('#qunit-test-output-00A'); assert.strictEqual( testOutput.textContent, - 'A (1)' + 'Rerun' + '2 ms' + 'boo' + '@ 1 ms' + - 'Expected: true' + - 'Result: false' + - 'Source: bar@example.js\nfoo@example.js\n@foo.test.js' + - 'Source: @foo.test.js', + 'A (1)' + 'Rerun' + '2 ms' + 'boo' + '@ 1 ms' + + 'Expected: true' + + 'Result: false' + + 'Source: bar@example.js\nfoo@example.js\n@foo.test.js' + + 'Source: @foo.test.js', 'test output' ); }); @@ -253,8 +253,8 @@ QUnit.test('onError [early]', function (assert) { var testItem = element.querySelector('#qunit-test-output-00A'); assert.strictEqual( testItem.textContent, - 'A (1)' + 'Rerun' + '0 ms' + - 'okay' + '@ 0 ms', + 'A (1)' + 'Rerun' + '0 ms' + + 'okay' + '@ 0 ms', 'test item (normal)' ); @@ -263,9 +263,9 @@ QUnit.test('onError [early]', function (assert) { assert.strictEqual(errorItem.id, '', 'error item, ID'); assert.strictEqual( errorItem.textContent, - 'global failure' + - 'Error: boo' + - 'Source: bar@example.js\nfoo@example.js\n@foo.test.js', + 'global failure' + + 'Error: boo' + + 'Source: bar@example.js\nfoo@example.js\n@foo.test.js', 'error item, text' ); }); @@ -287,8 +287,8 @@ QUnit.test('onError [mid-run]', function (assert) { var testItem = element.querySelector('#qunit-test-output-00A'); assert.strictEqual( testItem.textContent, - 'A (1)' + 'Rerun' + '0 ms' + - 'okay' + '@ 0 ms', + 'A (1)' + 'Rerun' + '0 ms' + + 'okay' + '@ 0 ms', 'test item (normal)' ); @@ -297,9 +297,9 @@ QUnit.test('onError [mid-run]', function (assert) { assert.strictEqual(errorItem.id, '', 'error item, ID'); assert.strictEqual( errorItem.textContent, - 'global failure' + - 'Error: boo' + - 'Source: bar@example.js\nfoo@example.js\n@foo.test.js', + 'global failure' + + 'Error: boo' + + 'Source: bar@example.js\nfoo@example.js\n@foo.test.js', 'error item, text' ); }); @@ -394,11 +394,11 @@ QUnit.test('options [urlConfig]', function (assert) { var node = element.querySelector('.qunit-url-config'); assert.strictEqual(node.innerHTML, this.normHTML( - '' + - '' + - '' + - '' + - '', + '' + + '' + + '' + + '' + + '', 'qunit-url-config HTML' )); }); @@ -590,13 +590,13 @@ QUnit.test('overall escaping', function (assert) { var testOutput = element.querySelector('#qunit-test-output-00A'); assert.strictEqual( testOutput.textContent, - ": (1, 1, 2)" + - 'Rerun' + - '1 ms' + - "@ 0 ms" + - "@ 1 ms" + - 'Expected: true' + - 'Result: false', + ": (1, 1, 2)" + + 'Rerun' + + '1 ms' + + "@ 0 ms" + + "@ 1 ms" + + 'Expected: true' + + 'Result: false', 'formatting of test output' ); diff --git a/test/main/TapReporter.js b/test/main/TapReporter.js index 03b4609de..44ba65462 100644 --- a/test/main/TapReporter.js +++ b/test/main/TapReporter.js @@ -1,8 +1,8 @@ function mockStack (error) { - error.stack = '' + - ' at Object. (/dev/null/test/unit/data.js:6:5)\n' + - ' at require (internal/helpers.js:22:18)\n' + - ' at /dev/null/src/example/foo.js:220:27'; + error.stack = '' + + ' at Object. (/dev/null/test/unit/data.js:6:5)\n' + + ' at require (internal/helpers.js:22:18)\n' + + ' at /dev/null/src/example/foo.js:220:27'; return error; } @@ -143,23 +143,23 @@ QUnit.module('TapReporter', function (hooks) { assertions: [] }); - assert.strictEqual(buffer, kleur.red('not ok 1 name') + '\n' + -' ---\n' + -' message: first error\n' + -' severity: failed\n' + -' stack: |\n' + -' at Object. (/dev/null/test/unit/data.js:6:5)\n' + -' at require (internal/helpers.js:22:18)\n' + -' at /dev/null/src/example/foo.js:220:27\n' + -' ...\n' + -' ---\n' + -' message: second error\n' + -' severity: failed\n' + -' stack: |\n' + -' at Object. (/dev/null/test/unit/data.js:6:5)\n' + -' at require (internal/helpers.js:22:18)\n' + -' at /dev/null/src/example/foo.js:220:27\n' + -' ...\n' + assert.strictEqual(buffer, kleur.red('not ok 1 name') + '\n' ++ ' ---\n' ++ ' message: first error\n' ++ ' severity: failed\n' ++ ' stack: |\n' ++ ' at Object. (/dev/null/test/unit/data.js:6:5)\n' ++ ' at require (internal/helpers.js:22:18)\n' ++ ' at /dev/null/src/example/foo.js:220:27\n' ++ ' ...\n' ++ ' ---\n' ++ ' message: second error\n' ++ ' severity: failed\n' ++ ' stack: |\n' ++ ' at Object. (/dev/null/test/unit/data.js:6:5)\n' ++ ' at require (internal/helpers.js:22:18)\n' ++ ' at /dev/null/src/example/foo.js:220:27\n' ++ ' ...\n' ); }); @@ -168,12 +168,12 @@ QUnit.module('TapReporter', function (hooks) { emitter.clear(); emitter.emit('error', 'Boo'); - assert.strictEqual(buffer, kleur.red('not ok 1 global failure') + '\n' + -' ---\n' + -' message: Boo\n' + -' severity: failed\n' + -' ...\n' + -'Bail out! Boo\n' + assert.strictEqual(buffer, kleur.red('not ok 1 global failure') + '\n' ++ ' ---\n' ++ ' message: Boo\n' ++ ' severity: failed\n' ++ ' ...\n' ++ 'Bail out! Boo\n' ); }); @@ -184,16 +184,16 @@ QUnit.module('TapReporter', function (hooks) { emitter.clear(); emitter.emit('error', err); - assert.strictEqual(buffer, kleur.red('not ok 1 global failure') + '\n' + -' ---\n' + -' message: ReferenceError: Boo is not defined\n' + -' severity: failed\n' + -' stack: |\n' + -' at Object. (/dev/null/test/unit/data.js:6:5)\n' + -' at require (internal/helpers.js:22:18)\n' + -' at /dev/null/src/example/foo.js:220:27\n' + -' ...\n' + -'Bail out! ReferenceError: Boo is not defined\n' + assert.strictEqual(buffer, kleur.red('not ok 1 global failure') + '\n' ++ ' ---\n' ++ ' message: ReferenceError: Boo is not defined\n' ++ ' severity: failed\n' ++ ' stack: |\n' ++ ' at Object. (/dev/null/test/unit/data.js:6:5)\n' ++ ' at require (internal/helpers.js:22:18)\n' ++ ' at /dev/null/src/example/foo.js:220:27\n' ++ ' ...\n' ++ 'Bail out! ReferenceError: Boo is not defined\n' ); }); @@ -211,34 +211,34 @@ QUnit.module('TapReporter', function (hooks) { }], assertions: null }); - assert.strictEqual(last, ' ---\n' + -' message: failed\n' + -' severity: failed\n' + -' actual : actual\n' + -' expected: Infinity\n' + -' ...' + assert.strictEqual(last, ' ---\n' ++ ' message: failed\n' ++ ' severity: failed\n' ++ ' actual : actual\n' ++ ' expected: Infinity\n' ++ ' ...' ); }); QUnit.test('output actual value of undefined', function (assert) { emitter.emit('testEnd', makeFailingTestEnd(undefined)); - assert.strictEqual(last, ' ---\n' + -' message: failed\n' + -' severity: failed\n' + -' actual : undefined\n' + -' expected: expected\n' + -' ...' + assert.strictEqual(last, ' ---\n' ++ ' message: failed\n' ++ ' severity: failed\n' ++ ' actual : undefined\n' ++ ' expected: expected\n' ++ ' ...' ); }); QUnit.test('output actual value of Infinity', function (assert) { emitter.emit('testEnd', makeFailingTestEnd(Infinity)); - assert.strictEqual(last, ' ---\n' + -' message: failed\n' + -' severity: failed\n' + -' actual : Infinity\n' + -' expected: expected\n' + -' ...' + assert.strictEqual(last, ' ---\n' ++ ' message: failed\n' ++ ' severity: failed\n' ++ ' actual : Infinity\n' ++ ' expected: expected\n' ++ ' ...' ); }); @@ -246,38 +246,38 @@ QUnit.module('TapReporter', function (hooks) { emitter.emit('testEnd', makeFailingTestEnd('abc')); // No redundant quotes - assert.strictEqual(last, ' ---\n' + -' message: failed\n' + -' severity: failed\n' + -' actual : abc\n' + -' expected: expected\n' + -' ...' + assert.strictEqual(last, ' ---\n' ++ ' message: failed\n' ++ ' severity: failed\n' ++ ' actual : abc\n' ++ ' expected: expected\n' ++ ' ...' ); }); QUnit.test('output actual value with one trailing line break', function (assert) { emitter.emit('testEnd', makeFailingTestEnd('abc\n')); - assert.strictEqual(last, ' ---\n' + -' message: failed\n' + -' severity: failed\n' + -' actual : |\n' + -' abc\n' + -' expected: expected\n' + -' ...' + assert.strictEqual(last, ' ---\n' ++ ' message: failed\n' ++ ' severity: failed\n' ++ ' actual : |\n' ++ ' abc\n' ++ ' expected: expected\n' ++ ' ...' ); }); QUnit.test('output actual value with two trailing line breaks', function (assert) { emitter.emit('testEnd', makeFailingTestEnd('abc\n\n')); - assert.strictEqual(last, ' ---\n' + -' message: failed\n' + -' severity: failed\n' + -' actual : |+\n' + -' abc\n' + -' \n' + -' \n' + -' expected: expected\n' + -' ...' + assert.strictEqual(last, ' ---\n' ++ ' message: failed\n' ++ ' severity: failed\n' ++ ' actual : |+\n' ++ ' abc\n' ++ ' \n' ++ ' \n' ++ ' expected: expected\n' ++ ' ...' ); }); @@ -285,12 +285,12 @@ QUnit.module('TapReporter', function (hooks) { emitter.emit('testEnd', makeFailingTestEnd('2')); // Quotes required to disambiguate YAML value - assert.strictEqual(last, ' ---\n' + -' message: failed\n' + -' severity: failed\n' + -' actual : "2"\n' + -' expected: expected\n' + -' ...' + assert.strictEqual(last, ' ---\n' ++ ' message: failed\n' ++ ' severity: failed\n' ++ ' actual : "2"\n' ++ ' expected: expected\n' ++ ' ...' ); }); @@ -298,34 +298,34 @@ QUnit.module('TapReporter', function (hooks) { emitter.emit('testEnd', makeFailingTestEnd('true')); // Quotes required to disambiguate YAML value - assert.strictEqual(last, ' ---\n' + -' message: failed\n' + -' severity: failed\n' + -' actual : "true"\n' + -' expected: expected\n' + -' ...' + assert.strictEqual(last, ' ---\n' ++ ' message: failed\n' ++ ' severity: failed\n' ++ ' actual : "true"\n' ++ ' expected: expected\n' ++ ' ...' ); }); QUnit.test('output actual value of 0', function (assert) { emitter.emit('testEnd', makeFailingTestEnd(0)); - assert.strictEqual(last, ' ---\n' + -' message: failed\n' + -' severity: failed\n' + -' actual : 0\n' + -' expected: expected\n' + -' ...' + assert.strictEqual(last, ' ---\n' ++ ' message: failed\n' ++ ' severity: failed\n' ++ ' actual : 0\n' ++ ' expected: expected\n' ++ ' ...' ); }); QUnit.test('output actual assertion value of empty array', function (assert) { emitter.emit('testEnd', makeFailingTestEnd([])); - assert.strictEqual(last, ' ---\n' + -' message: failed\n' + -' severity: failed\n' + -' actual : []\n' + -' expected: expected\n' + -' ...' + assert.strictEqual(last, ' ---\n' ++ ' message: failed\n' ++ ' severity: failed\n' ++ ' actual : []\n' ++ ' expected: expected\n' ++ ' ...' ); }); @@ -337,15 +337,15 @@ QUnit.module('TapReporter', function (hooks) { return cyclical; } emitter.emit('testEnd', makeFailingTestEnd(createCyclical())); - assert.strictEqual(last, ' ---\n' + -' message: failed\n' + -' severity: failed\n' + -' actual : {\n' + -' "a": "example",\n' + -' "cycle": "[Circular]"\n' + -'}\n' + -' expected: expected\n' + -' ...' + assert.strictEqual(last, ' ---\n' ++ ' message: failed\n' ++ ' severity: failed\n' ++ ' actual : {\n' ++ ' "a": "example",\n' ++ ' "cycle": "[Circular]"\n' ++ '}\n' ++ ' expected: expected\n' ++ ' ...' ); }); @@ -357,17 +357,17 @@ QUnit.module('TapReporter', function (hooks) { return cyclical; } emitter.emit('testEnd', makeFailingTestEnd(createSubobjectCyclical())); - assert.strictEqual(last, ' ---\n' + -' message: failed\n' + -' severity: failed\n' + -' actual : {\n' + -' "a": "example",\n' + -' "sub": {\n' + -' "cycle": "[Circular]"\n' + -' }\n' + -'}\n' + -' expected: expected\n' + -' ...' + assert.strictEqual(last, ' ---\n' ++ ' message: failed\n' ++ ' severity: failed\n' ++ ' actual : {\n' ++ ' "a": "example",\n' ++ ' "sub": {\n' ++ ' "cycle": "[Circular]"\n' ++ ' }\n' ++ '}\n' ++ ' expected: expected\n' ++ ' ...' ); }); @@ -379,18 +379,18 @@ QUnit.module('TapReporter', function (hooks) { return cyclical; } emitter.emit('testEnd', makeFailingTestEnd(createCyclicalArray())); - assert.strictEqual(last, ' ---\n' + -' message: failed\n' + -' severity: failed\n' + -' actual : {\n' + -' "sub": [\n' + -' "example",\n' + -' "[Circular]",\n' + -' "[Circular]"\n' + -' ]\n' + -'}\n' + -' expected: expected\n' + -' ...' + assert.strictEqual(last, ' ---\n' ++ ' message: failed\n' ++ ' severity: failed\n' ++ ' actual : {\n' ++ ' "sub": [\n' ++ ' "example",\n' ++ ' "[Circular]",\n' ++ ' "[Circular]"\n' ++ ' ]\n' ++ '}\n' ++ ' expected: expected\n' ++ ' ...' ); }); @@ -408,20 +408,20 @@ QUnit.module('TapReporter', function (hooks) { }; } emitter.emit('testEnd', makeFailingTestEnd(createDuplicateAcyclical())); - assert.strictEqual(last, ' ---\n' + -' message: failed\n' + -' severity: failed\n' + -' actual : {\n' + -' "a": {\n' + -' "example": "value"\n' + -' },\n' + -' "b": {\n' + -' "example": "value"\n' + -' },\n' + -' "c": "unique"\n' + -'}\n' + -' expected: expected\n' + -' ...' + assert.strictEqual(last, ' ---\n' ++ ' message: failed\n' ++ ' severity: failed\n' ++ ' actual : {\n' ++ ' "a": {\n' ++ ' "example": "value"\n' ++ ' },\n' ++ ' "b": {\n' ++ ' "example": "value"\n' ++ ' },\n' ++ ' "c": "unique"\n' ++ '}\n' ++ ' expected: expected\n' ++ ' ...' ); }); @@ -436,8 +436,8 @@ QUnit.module('TapReporter', function (hooks) { } }); - assert.strictEqual(buffer, '1..6\n' + -'# pass 3\n' + kleur.yellow('# skip 1') + '\n' + kleur.cyan('# todo 0') + '\n' + kleur.red('# fail 2') + '\n' + assert.strictEqual(buffer, '1..6\n' ++ '# pass 3\n' + kleur.yellow('# skip 1') + '\n' + kleur.cyan('# todo 0') + '\n' + kleur.red('# fail 2') + '\n' ); }); }); diff --git a/test/main/assert-es6.js b/test/main/assert-es6.js index b9d34d887..8f3d9da9b 100644 --- a/test/main/assert-es6.js +++ b/test/main/assert-es6.js @@ -53,9 +53,9 @@ QUnit.module('assert [es6]', function () { hooks.beforeEach(function (assert) { const original = assert.pushResult; assert.pushResult = (resultInfo) => { - if (this.expectedFailure && - this.expectedFailure.actual === resultInfo.actual && - this.expectedFailure.expected.test(resultInfo.expected) + if (this.expectedFailure + && this.expectedFailure.actual === resultInfo.actual + && this.expectedFailure.expected.test(resultInfo.expected) ) { // Restore assert.pushResult = original; diff --git a/test/main/diff.js b/test/main/diff.js index c1f450a73..2664e1a24 100644 --- a/test/main/diff.js +++ b/test/main/diff.js @@ -89,30 +89,30 @@ QUnit.test('equality shifts', function (assert) { }); QUnit.test('test with line mode on long strings', function (assert) { - var a = 'QUnit is a powerful, easy-to-use JavaScript unit testing framework. ' + - "It's used by the jQuery, jQuery UI and jQuery Mobile projects and is " + - 'capable of testing any generic JavaScript code, including itself!'; + var a = 'QUnit is a powerful, easy-to-use JavaScript unit testing framework. ' + + "It's used by the jQuery, jQuery UI and jQuery Mobile projects and is " + + 'capable of testing any generic JavaScript code, including itself!'; - var b = 'QUnit is a very powerful, easy-to-use JavaScript unit testing framework. ' + - "It's used by the jQuery Core, jQuery UI and jQuery Mobile projects and is " + - 'capable of testing any JavaScript code, including itself!' + - 'QUnit was originally developed by John Resig as part of jQuery. In 2008 ' + - 'it got its own home, name and API documentation, allowing others to use it ' + - 'for their unit testing as well. At the time it still depended on jQuery. ' + - 'A rewrite in 2009 fixed that, and now QUnit runs completely standalone. '; + var b = 'QUnit is a very powerful, easy-to-use JavaScript unit testing framework. ' + + "It's used by the jQuery Core, jQuery UI and jQuery Mobile projects and is " + + 'capable of testing any JavaScript code, including itself!' + + 'QUnit was originally developed by John Resig as part of jQuery. In 2008 ' + + 'it got its own home, name and API documentation, allowing others to use it ' + + 'for their unit testing as well. At the time it still depended on jQuery. ' + + 'A rewrite in 2009 fixed that, and now QUnit runs completely standalone. '; assert.equal( QUnit.diff(a, b), - 'QUnit is a very powerful, easy-to-use ' + - 'JavaScript unit testing framework. It's used by the jQuery ' + - 'Core, jQuery UI and jQuery Mobile projects and is capable of' + - ' testing any generic JavaScript code, including ' + - 'itself!' + - 'QUnit was originally developed by John Resig as part of jQuery. In ' + - '2008 it got its own home, name and API documentation, allowing others to' + - ' use it for their unit testing as well. At the time it still depended on' + - ' jQuery. A rewrite in 2009 fixed that, and now QUnit runs completely ' + - 'standalone. ' + 'QUnit is a very powerful, easy-to-use ' + + 'JavaScript unit testing framework. It's used by the jQuery ' + + 'Core, jQuery UI and jQuery Mobile projects and is capable of' + + ' testing any generic JavaScript code, including ' + + 'itself!' + + 'QUnit was originally developed by John Resig as part of jQuery. In ' + + '2008 it got its own home, name and API documentation, allowing others to' + + ' use it for their unit testing as well. At the time it still depended on' + + ' jQuery. A rewrite in 2009 fixed that, and now QUnit runs completely ' + + 'standalone. ' ); }); @@ -150,15 +150,15 @@ QUnit.test('simplified diffs', function (assert) { 'before 0foobarbaz0foobarbaz0foobarbaz0foobarbaz0foobarbaz0foobarbaz0foobarbaz more than 100 chars\nsecond_line', 'after 1foobarbaz1foobarbaz1foobarbaz1foobarbaz1foobarbaz1foobarbaz1foobarbaz more than 100 chars\ndifferent_end' ), - 'before 0after 1' + - 'foobarbaz01' + - 'foobarbaz01' + - 'foobarbaz01' + - 'foobarbaz01' + - 'foobarbaz01' + - 'foobarbaz01' + - 'foobarbaz more than 100 chars\n' + - 'second_lifferent_end', + 'before 0after 1' + + 'foobarbaz01' + + 'foobarbaz01' + + 'foobarbaz01' + + 'foobarbaz01' + + 'foobarbaz01' + + 'foobarbaz01' + + 'foobarbaz more than 100 chars\n' + + 'second_lifferent_end', 'simplify longer multi-line diffs' ); }); @@ -189,9 +189,9 @@ QUnit.test('Edge cases', function (assert) { QUnit.diff( 'A\nB\n' + X + '\nD', 'A\nCCC\nB\nCCC\n' + Y + '\nD'), - 'A\nCCC\nB\n' + - '' + X + 'CCC\n' + Y + '' + - '\nD'); + 'A\nCCC\nB\n' + + '' + X + 'CCC\n' + Y + '' + + '\nD'); function repeat (substr, n) { if (substr.repeat) { diff --git a/test/main/test.js b/test/main/test.js index 46ec0bc46..970088789 100644 --- a/test/main/test.js +++ b/test/main/test.js @@ -224,9 +224,9 @@ QUnit.module('test', function () { }); QUnit.test('assertions after test finishes throws an error - part 2', function (assert) { - var error = 'Assertion occurred after test finished.\n' + - '> Test: ' + firstTestName + '\n' + - '> Message: message here\n'; + var error = 'Assertion occurred after test finished.\n' + + '> Test: ' + firstTestName + '\n' + + '> Message: message here\n'; assert.throws(function () { previousTestAssert.true(true, 'message here'); diff --git a/test/reporter-urlparams.js b/test/reporter-urlparams.js index 727f9f513..8e2c2203f 100644 --- a/test/reporter-urlparams.js +++ b/test/reporter-urlparams.js @@ -1,8 +1,8 @@ /* eslint-env browser */ if (!location.search) { - location.replace('?implicit&explicit=yes&array=A&array=B&escaped%20name&toString=string&' + - 'module=urlParams+module&filter=urlParams%20module¬rycatch&' + - 'custom&customArray=a&customArray=b&customMenu=b&customMenuUnknown=c&altertitle=x&collapse=x'); + location.replace('?implicit&explicit=yes&array=A&array=B&escaped%20name&toString=string&' + + 'module=urlParams+module&filter=urlParams%20module¬rycatch&' + + 'custom&customArray=a&customArray=b&customMenu=b&customMenuUnknown=c&altertitle=x&collapse=x'); } QUnit.config.urlConfig.push(