update tests

pull/10904/head
Rich Harris 2 years ago
parent 3fc818feba
commit ca18d8acc4

@ -135,15 +135,15 @@ export function setup_html_equal(options = {}) {
try {
assert.deepEqual(
withoutNormalizeHtml
? normalize_new_line(actual)
? normalize_new_line(actual.trim())
.replace(/(\sdata-svelte-h="[^"]+")/g, options.removeDataSvelte ? '' : '$1')
.replace(/(<!(--)?.*?\2>)/g, preserveComments !== false ? '$1' : '')
: normalize_html(window, actual, { ...options, preserveComments }),
: normalize_html(window, actual.trim(), { ...options, preserveComments }),
withoutNormalizeHtml
? normalize_new_line(expected)
? normalize_new_line(expected.trim())
.replace(/(\sdata-svelte-h="[^"]+")/g, options.removeDataSvelte ? '' : '$1')
.replace(/(<!(--)?.*?\2>)/g, preserveComments !== false ? '$1' : '')
: normalize_html(window, expected, { ...options, preserveComments }),
: normalize_html(window, expected.trim(), { ...options, preserveComments }),
message
);
} catch (e) {

@ -12,7 +12,7 @@ function get_html(ssr) {
// ssr rendered HTML has an extra newline prefixed within `<pre>` tag,
// if the <pre> tag starts with `\n`
// because when browser parses the SSR rendered HTML, it will ignore the 1st '\n' character
return `${ssr ? '<!--ssr:0-->' : ''}<pre id="pre"> A
return `${ssr ? '<!--[-->' : ''}<pre id="pre"> A
B
<span>
C
@ -35,5 +35,5 @@ function get_html(ssr) {
leading newlines</pre></div> <div id="pre-without-leading-newline"><pre>without spaces</pre> <pre> with spaces </pre> <pre>${' '}
newline after leading space</pre></div> <pre id="pre-with-multiple-leading-newlines">
multiple leading newlines</pre>${ssr ? '<!--ssr:0-->' : ''}`;
multiple leading newlines</pre>${ssr ? '<!--]-->' : ''}`;
}

@ -11,7 +11,7 @@ export default test({
if (variant === 'dom') {
assert.ok(!span.previousSibling);
} else {
assert.ok(span.previousSibling?.textContent?.startsWith('ssr:')); // ssr commment node
assert.ok(span.previousSibling?.textContent === '['); // ssr commment node
}
component.raw = '<span>bar</span>';

@ -4,17 +4,17 @@ export default test({
withoutNormalizeHtml: true,
// Unable to test `html` with `<textarea>` content
// as the textarea#value will not show within `innerHtml`
ssrHtml: `<!--ssr:0--><textarea id="textarea"> A
ssrHtml: `<!--[--><textarea id="textarea"> A
B
</textarea> <div id="div-with-textarea"><textarea> A
B
</textarea></div> <div id="textarea-with-leading-newline"><textarea>leading newline</textarea> <textarea> leading newline and spaces</textarea> <textarea>
leading newlines</textarea></div> <div id="textarea-without-leading-newline"><textarea>without spaces</textarea> <textarea> with spaces </textarea> <textarea>
leading newlines</textarea></div> <div id="textarea-without-leading-newline"><textarea>without spaces</textarea> <textarea> with spaces </textarea> <textarea>${' '}
newline after leading space</textarea></div> <textarea id="textarea-with-multiple-leading-newlines">
multiple leading newlines</textarea> <div id="div-with-textarea-with-multiple-leading-newlines"><textarea>
multiple leading newlines</textarea></div><!--ssr:0-->`,
multiple leading newlines</textarea></div><!--]-->`,
test({ assert, target }) {
// Test for <textarea> tag
const elementTextarea = /** @type {HTMLTextAreaElement} */ (target.querySelector('#textarea'));

@ -1,5 +1 @@
<!--ssr:0-->
<p>before</p>
<!-- a comment -->
<p>after</p>
<!--ssr:0-->
<![><p>before</p><!-- a comment --><p>after</p><!]>

@ -1 +1 @@
<!ssr:0><div>Just a dummy page.</div><!ssr:0>
<![><div>Just a dummy page.</div><!]>

Loading…
Cancel
Save