Skip to content

Commit cdb2bba

Browse files
committed
Tweak DOMElement.inspect
1 parent fd77ff3 commit cdb2bba

File tree

2 files changed

+60
-12
lines changed

2 files changed

+60
-12
lines changed

lib/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -540,11 +540,11 @@ module.exports = {
540540
}
541541
}
542542

543-
var width = 0;
543+
var width = startTag.length;
544544
var multipleLines = inspectedChildren.some(function(o) {
545545
var size = o.size();
546546
width += size.width;
547-
return width > 50 || o.height > 1;
547+
return width > 60 || o.height > 1;
548548
});
549549

550550
if (multipleLines) {

test/index.spec.js

+58-10
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,11 @@ describe('unexpected-dom', function() {
408408
expect(body.firstChild, 'to have class', 'quux');
409409
},
410410
'to throw',
411-
'expected <button class="bar" data-info="baz" disabled id="foo">Press me</button> to have class \'quux\'\n' +
411+
'expected\n' +
412+
'<button class="bar" data-info="baz" disabled id="foo">\n' +
413+
' Press me\n' +
414+
'</button>\n' +
415+
"to have class 'quux'\n" +
412416
'\n' +
413417
'<button\n' +
414418
' id="foo"\n' +
@@ -435,7 +439,10 @@ describe('unexpected-dom', function() {
435439
expect(body.firstChild, 'to have classes', ['quux', 'bar']);
436440
},
437441
'to throw',
438-
'expected <button class="bar" data-info="baz" disabled id="foo">Press me</button>\n' +
442+
'expected\n' +
443+
'<button class="bar" data-info="baz" disabled id="foo">\n' +
444+
' Press me\n' +
445+
'</button>\n' +
439446
"to have classes [ 'quux', 'bar' ]\n" +
440447
'\n' +
441448
'<button\n' +
@@ -464,7 +471,10 @@ describe('unexpected-dom', function() {
464471
expect(body.firstChild, 'to only have class', 'quux');
465472
},
466473
'to throw',
467-
'expected <button class="bar quux" data-info="baz" disabled id="foo">Press me</button>\n' +
474+
'expected\n' +
475+
'<button class="bar quux" data-info="baz" disabled id="foo">\n' +
476+
' Press me\n' +
477+
'</button>\n' +
468478
"to only have class 'quux'\n" +
469479
'\n' +
470480
'<button\n' +
@@ -497,7 +507,10 @@ describe('unexpected-dom', function() {
497507
expect(body.firstChild, 'to only have classes', ['quux', 'bar']);
498508
},
499509
'to throw',
500-
'expected <button class="bar quux foo" data-info="baz" disabled id="foo">Press me</button>\n' +
510+
'expected\n' +
511+
'<button class="bar quux foo" data-info="baz" disabled id="foo">\n' +
512+
' Press me\n' +
513+
'</button>\n' +
501514
"to only have classes [ 'bar', 'quux' ]\n" +
502515
'\n' +
503516
'<button\n' +
@@ -544,7 +557,10 @@ describe('unexpected-dom', function() {
544557
expect(el, 'to only have attributes', 'id');
545558
},
546559
'to throw',
547-
'expected <button class="bar" data-info="baz" disabled id="foo">Press me</button>\n' +
560+
'expected\n' +
561+
'<button class="bar" data-info="baz" disabled id="foo">\n' +
562+
' Press me\n' +
563+
'</button>\n' +
548564
"to only have attributes 'id'\n" +
549565
'\n' +
550566
'<button\n' +
@@ -573,7 +589,10 @@ describe('unexpected-dom', function() {
573589
expect(el, 'to have attributes', 'id', 'foo');
574590
},
575591
'to throw',
576-
'expected <button class="bar" data-info="baz" disabled id="foo">Press me</button>\n' +
592+
'expected\n' +
593+
'<button class="bar" data-info="baz" disabled id="foo">\n' +
594+
' Press me\n' +
595+
'</button>\n' +
577596
"to have attributes 'id', 'foo'\n" +
578597
'\n' +
579598
'<button\n' +
@@ -610,7 +629,10 @@ describe('unexpected-dom', function() {
610629
expect(el, 'to only have attributes', ['id']);
611630
},
612631
'to throw',
613-
'expected <button class="bar" data-info="baz" disabled id="foo">Press me</button>\n' +
632+
'expected\n' +
633+
'<button class="bar" data-info="baz" disabled id="foo">\n' +
634+
' Press me\n' +
635+
'</button>\n' +
614636
"to only have attributes [ 'id' ]\n" +
615637
'\n' +
616638
'<button\n' +
@@ -639,7 +661,10 @@ describe('unexpected-dom', function() {
639661
expect(el, 'to have attributes', ['id', 'foo']);
640662
},
641663
'to throw',
642-
'expected <button class="bar" data-info="baz" disabled id="foo">Press me</button>\n' +
664+
'expected\n' +
665+
'<button class="bar" data-info="baz" disabled id="foo">\n' +
666+
' Press me\n' +
667+
'</button>\n' +
643668
"to have attributes [ 'id', 'foo' ]\n" +
644669
'\n' +
645670
'<button\n' +
@@ -705,7 +730,18 @@ describe('unexpected-dom', function() {
705730
});
706731
},
707732
'to throw',
708-
/^expected <button class="bar" data-info="baz" disabled id="foo">Press me<\/button>\nto only have attributes/
733+
'expected\n' +
734+
'<button class="bar" data-info="baz" disabled id="foo">\n' +
735+
' Press me\n' +
736+
'</button>\n' +
737+
"to only have attributes { id: 'foo' }\n" +
738+
'\n' +
739+
'<button\n' +
740+
' id="foo"\n' +
741+
' class="bar" // should be removed\n' +
742+
' data-info="baz" // should be removed\n' +
743+
' disabled // should be removed\n' +
744+
'>Press me</button>'
709745
);
710746
});
711747

@@ -732,7 +768,19 @@ describe('unexpected-dom', function() {
732768
});
733769
},
734770
'to throw',
735-
/expected <button class="bar" data-info="baz" disabled id="foo">Press me<\/button>\nto have attributes/
771+
'expected\n' +
772+
'<button class="bar" data-info="baz" disabled id="foo">\n' +
773+
' Press me\n' +
774+
'</button>\n' +
775+
"to have attributes { id: 'foo', foo: 'bar' }\n" +
776+
'\n' +
777+
'<button\n' +
778+
' id="foo"\n' +
779+
' class="bar"\n' +
780+
' data-info="baz"\n' +
781+
' disabled\n' +
782+
" // missing foo should equal 'bar'\n" +
783+
'>Press me</button>'
736784
);
737785
});
738786

0 commit comments

Comments
 (0)