chore: render into a fragment in tests

pull/18058/head
paoloricciuti 5 months ago
parent 0f44733183
commit beddf45690

@ -176,10 +176,10 @@ const renderer = createRenderer({
/** /**
* Create a root object for mounting components into. * Create a root object for mounting components into.
* @returns {ObjElement} * @returns {ObjFragment}
*/ */
export function create_root() { export function create_root() {
return renderer.createElement('root'); return renderer.createFragment();
} }
/** /**

@ -5,7 +5,7 @@ export default test({
const html = serialize(target); const html = serialize(target);
assert.equal( assert.equal(
html, html,
'<root><div class="container" data-color="red"><span id="label">colored</span></div></root>' '<div class="container" data-color="red"><span id="label">colored</span></div>'
); );
// Verify individual attribute access on the object node // Verify individual attribute access on the object node

@ -25,9 +25,6 @@ export default test({
flushSync(); flushSync();
const html = serialize(target); const html = serialize(target);
assert.equal( assert.equal(html, '<p>hello</p> <p>Something inside</p> <p>Something outside</p>');
html,
'<root><p>hello</p> <p>Something inside</p> <p>Something outside</p></root>'
);
} }
}); });

@ -13,12 +13,12 @@ export default test({
flushSync(); flushSync();
let html = serialize(target); let html = serialize(target);
assert.equal(html, '<root><p>hidden</p> <button>toggle</button></root>'); assert.equal(html, '<p>hidden</p> <button>toggle</button>');
dispatch_event(button, 'click'); dispatch_event(button, 'click');
flushSync(); flushSync();
html = serialize(target); html = serialize(target);
assert.equal(html, '<root><p>visible</p> <button>toggle</button></root>'); assert.equal(html, '<p>visible</p> <button>toggle</button>');
} }
}); });

@ -13,13 +13,13 @@ export default test({
flushSync(); flushSync();
const html = serialize(target); const html = serialize(target);
assert.equal(html, '<root><button>click me</button> <p>1</p></root>'); assert.equal(html, '<button>click me</button> <p>1</p>');
dispatch_event(button, 'click'); dispatch_event(button, 'click');
dispatch_event(button, 'click'); dispatch_event(button, 'click');
flushSync(); flushSync();
const html2 = serialize(target); const html2 = serialize(target);
assert.equal(html2, '<root><button>click me</button> <p>3</p></root>'); assert.equal(html2, '<button>click me</button> <p>3</p>');
} }
}); });

@ -13,6 +13,6 @@ export default test({
flushSync(); flushSync();
const html = serialize(target); const html = serialize(target);
assert.equal(html, '<root><button>clicks: 1</button></root>'); assert.equal(html, '<button>clicks: 1</button>');
} }
}); });

@ -129,7 +129,7 @@ async function run_test(cwd: string, config: CustomRendererTest, compile_options
if (config.html) { if (config.html) {
const html = serialize(target); const html = serialize(target);
assert.equal(html, `<root>${config.html}</root>`); assert.equal(html, config.html);
} }
try { try {
@ -160,11 +160,7 @@ async function run_test(cwd: string, config: CustomRendererTest, compile_options
// After unmount the target should be empty (only comments remain, which serialize to '') // After unmount the target should be empty (only comments remain, which serialize to '')
const remaining = serialize(target); const remaining = serialize(target);
assert.equal( assert.equal(remaining, '', 'Expected component to leave nothing behind after unmount');
remaining,
'<root></root>',
'Expected component to leave nothing behind after unmount'
);
} }
} catch (err) { } catch (err) {
if (config.runtime_error) { if (config.runtime_error) {

Loading…
Cancel
Save