Skip to content

Commit

Permalink
Core: Remove unused and undocumented QUnit.dump.HTML and `QUnit.dum…
Browse files Browse the repository at this point in the history
…p.multiline`

These have been unused and undocumented since QUnit 1.0.0, with
as part of the embedded jsDump library.

In searching public git.luolix.top-hosted repositories, I found (apart
from copies of qunit.js and its own tests):

* 1 use of QUnit.dump.HTML (riboseinc/jquery-bbq), which appears
  redundant as it sets false, and will be gracefully ignored either
  way as unused created property if kept as setting after QUnit 3.0.

* 1 use of QUnit.dump.multiline (Morgas01/Morgas.js), which appears
  to be a preference not mechanically relied upon. This will no longer
  be supported in QUnit 3.0, and will be silently ignored in QUnit 3.0.
  • Loading branch information
Krinkle committed Jul 14, 2024
1 parent 1551120 commit 8e881f5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 58 deletions.
24 changes: 4 additions & 20 deletions src/dump.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,22 +140,12 @@ export default (function () {
},

separator: function () {
if (this.multiline) {
return this.HTML ? '<br />' : '\n';
} else {
return this.HTML ? '&#160;' : ' ';
}
return '\n';
},

// Extra can be a number, shortcut for increasing-calling-decreasing
indent: function (extra) {
if (!this.multiline) {
return '';
}
let chr = this.indentChar;
if (this.HTML) {
chr = chr.replace(/\t/g, ' ').replace(/ /g, '&#160;');
}
return new Array(this.depth + (extra || 0)).join(chr);
},
up: function (a) {
Expand Down Expand Up @@ -237,8 +227,8 @@ export default (function () {
return join('{', ret, '}');
},
node: function (node) {
const open = dump.HTML ? '&lt;' : '<';
const close = dump.HTML ? '&gt;' : '>';
const open = '<';
const close = '>';
const tag = node.nodeName.toLowerCase();
let ret = open + tag;
const attrs = node.attributes;
Expand Down Expand Up @@ -300,14 +290,8 @@ export default (function () {
}
},

// If true, entities are escaped ( <, >, \t, space and \n )
HTML: false,

// Indentation unit
indentChar: ' ',

// If true, items in a collection, are separated by a \n, else just a space.
multiline: true
indentChar: ' '
};

return dump;
Expand Down
54 changes: 16 additions & 38 deletions test/main/dump.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,6 @@ QUnit.test('error [subclass]', function (assert) {
});
});

QUnit.test('array [shallow]', function (assert) {
QUnit.dump.maxDepth = 1;
assert.equal(
QUnit.dump.parse([[]]),
'[\n [object Array]\n]');
});

QUnit.test('regex', function (assert) {
assert.equal(QUnit.dump.parse(/foo/), '/foo/');
});
Expand Down Expand Up @@ -141,30 +134,6 @@ QUnit.test('function [unnamed]', function (assert) {
assert.equal(QUnit.dump.parse(f), 'function( a, b ){\n [code]\n}');
});

QUnit.test('array [multiline=false]', function (assert) {
QUnit.dump.multiline = false;

assert.equal(QUnit.dump.parse([[]]), '[ [] ]');

QUnit.dump.multiline = true;
});

QUnit.test('array [HTML=true]', function (assert) {
QUnit.dump.HTML = true;

assert.equal(
QUnit.dump.parse([1, 2]),
'[<br />&#160;&#160;1,<br />&#160;&#160;2<br />]');

QUnit.dump.multiline = false;
assert.equal(
QUnit.dump.parse([1, 2]),
'[&#160;1,&#160;2&#160;]');

QUnit.dump.multiline = true;
QUnit.dump.HTML = false;
});

QUnit.test('window, document, node [fake]', function (assert) {
var fakeWindow = {
setInterval: [],
Expand All @@ -184,13 +153,6 @@ QUnit.test('window, document, node [fake]', function (assert) {
assert.equal(
QUnit.dump.parse(fakeTextNode),
'<faketextnode>fakeValue</faketextnode>');

QUnit.dump.HTML = true;
assert.equal(
QUnit.dump.parse(fakeTextNode),
'&lt;faketextnode&gt;fakeValue&lt;/faketextnode&gt;');

QUnit.dump.HTML = false;
});

QUnit.test.if('node [real DOM]', typeof document !== 'undefined', function (assert) {
Expand Down Expand Up @@ -279,6 +241,22 @@ QUnit.test('object equal/deepEqual [recursion]', function (assert) {
assert.deepEqual(circref, circref, '... and checked on all levels!');
});

QUnit.test('array [basic]', function (assert) {
assert.equal(QUnit.dump.parse([[]]), '[\n []\n]');

assert.equal(
QUnit.dump.parse([1, 2]),
'[\n 1,\n 2\n]'
);
});

QUnit.test('array [shallow]', function (assert) {
QUnit.dump.maxDepth = 1;
assert.equal(
QUnit.dump.parse([[]]),
'[\n [object Array]\n]');
});

QUnit.test('array [recursion]', function (assert) {
// Pure array self-ref
var arr = [];
Expand Down

0 comments on commit 8e881f5

Please sign in to comment.