unexpected-htmllike
Advanced tools
Comparing version 0.3.0 to 0.3.1
@@ -10,2 +10,9 @@ | ||
letting children that are the same element be similar, and then we take the result with the best weight. | ||
* Tests improved using preferredWidth for magicpen - they should now run everywhere! | ||
* Tests improved using preferredWidth for magicpen - they should now run everywhere! | ||
### v0.3.0 | ||
* Asynchronous diffing, | ||
* support for expect.it(...), including asynchronous assertions | ||
### v0.3.1 | ||
* Minor improvements to display of elements with children with attributes that need more than one line |
@@ -186,7 +186,12 @@ 'use strict'; | ||
var forceChildrenOnNewLine = false; | ||
var needNewLineBeforeClose = false; | ||
if (description.attributes) { | ||
var penSize = outputAttributes(pen, description.attributes, inspect, diffFn); | ||
if (penSize.height > 1) { | ||
var attributeResult = outputAttributes(pen, description.attributes, inspect, diffFn); | ||
if (attributeResult.size.height > 1) { | ||
needSpaceBeforeSelfClose = false; | ||
forceChildrenOnNewLine = true; | ||
if (!attributeResult.breakAfter) { | ||
needNewLineBeforeClose = true; | ||
} | ||
} | ||
@@ -199,2 +204,6 @@ } | ||
} | ||
if (needNewLineBeforeClose) { | ||
pen.nl().i(); | ||
} | ||
pen.prismPunctuation('/>'); | ||
@@ -342,7 +351,10 @@ } else { | ||
var attribPen = attribOutput.getOutput({ groupContent: true, appendBreakIfHadBreaks: true }).output; | ||
pen.append(attribPen); | ||
return attribPen.size(); | ||
var attribResult = attribOutput.getOutput({ groupContent: true, appendBreakIfHadBreaks: false }); | ||
pen.append(attribResult.output); | ||
return { | ||
size: attribResult.output.size(), | ||
breakAfter: attribResult.breakAfter | ||
}; | ||
} | ||
module.exports = exports['default']; | ||
//# sourceMappingURL=painter.js.map |
@@ -304,3 +304,3 @@ | ||
children: ['some content'] | ||
}, 'to inspect as', '<div id="foo" className="bar blah mcgar" data-role="special-long-button"\n' + ' data-special="some other long attrib"\n' + '>\n' + ' some content\n' + '</div>'); | ||
}, 'to inspect as', '<div id="foo" className="bar blah mcgar" data-role="special-long-button"\n' + ' data-special="some other long attrib">\n' + ' some content\n' + '</div>'); | ||
}); | ||
@@ -307,0 +307,0 @@ |
@@ -186,2 +186,17 @@ 'use strict'; | ||
it('outputs many attributes over multiple lines', function () { | ||
(0, _painter2['default'])(pen, { | ||
type: 'ELEMENT', | ||
name: 'div', | ||
attributes: [{ name: 'id', value: 'very-long-attribute-value' }, { name: 'data-value1', value: 'very-long-attribute-value' }, { name: 'data-value2', value: 'very-long-attribute-value' }], | ||
children: [{ | ||
type: 'CONTENT', | ||
value: 'one' | ||
}] | ||
}, expect.inspect, expect.diff); | ||
expect(pen.toString(), 'to equal', '<div id="very-long-attribute-value" data-value1="very-long-attribute-value"\n' + ' data-value2="very-long-attribute-value">\n' + ' one\n' + '</div>'); | ||
}); | ||
it('forces the children onto multiple lines when attributes are on multiple lines', function () { | ||
@@ -188,0 +203,0 @@ |
{ | ||
"name": "unexpected-htmllike", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "Helper library for unexpected plugins that perform assertions on XML like structures", | ||
@@ -5,0 +5,0 @@ "author": { |
@@ -189,7 +189,12 @@ | ||
let forceChildrenOnNewLine = false; | ||
let needNewLineBeforeClose = false; | ||
if (description.attributes) { | ||
const penSize = outputAttributes(pen, description.attributes, inspect, diffFn); | ||
if (penSize.height > 1) { | ||
const attributeResult = outputAttributes(pen, description.attributes, inspect, diffFn); | ||
if (attributeResult.size.height > 1) { | ||
needSpaceBeforeSelfClose = false; | ||
forceChildrenOnNewLine = true; | ||
if (!attributeResult.breakAfter) { | ||
needNewLineBeforeClose = true; | ||
} | ||
} | ||
@@ -203,2 +208,6 @@ } | ||
} | ||
if (needNewLineBeforeClose) { | ||
pen.nl().i(); | ||
} | ||
pen.prismPunctuation('/>'); | ||
@@ -357,5 +366,8 @@ } else { | ||
const attribPen = attribOutput.getOutput({ groupContent: true, appendBreakIfHadBreaks: true }).output; | ||
pen.append(attribPen); | ||
return attribPen.size(); | ||
const attribResult = attribOutput.getOutput({ groupContent: true, appendBreakIfHadBreaks: false }); | ||
pen.append(attribResult.output); | ||
return { | ||
size: attribResult.output.size(), | ||
breakAfter: attribResult.breakAfter | ||
}; | ||
} |
@@ -244,2 +244,25 @@ | ||
it('outputs many attributes over multiple lines', () => { | ||
Painter(pen, { | ||
type: 'ELEMENT', | ||
name: 'div', | ||
attributes: [ | ||
{ name: 'id', value: 'very-long-attribute-value' }, | ||
{ name: 'data-value1', value: 'very-long-attribute-value' }, | ||
{ name: 'data-value2', value: 'very-long-attribute-value' } | ||
], | ||
children: [ { | ||
type: 'CONTENT', | ||
value: 'one' | ||
}] | ||
}, expect.inspect, expect.diff); | ||
expect(pen.toString(), 'to equal', | ||
'<div id="very-long-attribute-value" data-value1="very-long-attribute-value"\n' + | ||
' data-value2="very-long-attribute-value">\n' + | ||
' one\n' + | ||
'</div>'); | ||
}); | ||
it('forces the children onto multiple lines when attributes are on multiple lines', () => { | ||
@@ -246,0 +269,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1044680
9492