mirror of
https://github.com/sveltejs/svelte.git
synced 2024-12-01 17:30:59 +01:00
tweak htmlEqual helper so tests are easier to write
This commit is contained in:
parent
8b3f0320f6
commit
2c4c7079e5
@ -71,12 +71,8 @@ function cleanChildren ( node ) {
|
|||||||
|
|
||||||
child.data = child.data.replace( /\s{2,}/, '\n' );
|
child.data = child.data.replace( /\s{2,}/, '\n' );
|
||||||
|
|
||||||
if ( child.data === '\n' ) {
|
|
||||||
node.removeChild( child );
|
|
||||||
}
|
|
||||||
|
|
||||||
// text
|
// text
|
||||||
else if ( previous && previous.nodeType === 3 ) {
|
if ( previous && previous.nodeType === 3 ) {
|
||||||
previous.data += child.data;
|
previous.data += child.data;
|
||||||
previous.data = previous.data.replace( /\s{2,}/, '\n' );
|
previous.data = previous.data.replace( /\s{2,}/, '\n' );
|
||||||
|
|
||||||
@ -106,11 +102,11 @@ function cleanChildren ( node ) {
|
|||||||
export function setupHtmlEqual () {
|
export function setupHtmlEqual () {
|
||||||
return env().then( window => {
|
return env().then( window => {
|
||||||
assert.htmlEqual = ( actual, expected, message ) => {
|
assert.htmlEqual = ( actual, expected, message ) => {
|
||||||
window.document.body.innerHTML = actual.trim();
|
window.document.body.innerHTML = actual.replace( />[\s\r\n]+</g, '><' ).trim();
|
||||||
cleanChildren( window.document.body, '' );
|
cleanChildren( window.document.body, '' );
|
||||||
actual = window.document.body.innerHTML;
|
actual = window.document.body.innerHTML;
|
||||||
|
|
||||||
window.document.body.innerHTML = expected.trim();
|
window.document.body.innerHTML = expected.replace( />[\s\r\n]+</g, '><' ).trim();
|
||||||
cleanChildren( window.document.body, '' );
|
cleanChildren( window.document.body, '' );
|
||||||
expected = window.document.body.innerHTML;
|
expected = window.document.body.innerHTML;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user