chore: render into a fragment in tests

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

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

@ -5,7 +5,7 @@ export default test({
const html = serialize(target);
assert.equal(
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

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

@ -13,12 +13,12 @@ export default test({
flushSync();
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');
flushSync();
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();
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');
flushSync();
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();
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) {
const html = serialize(target);
assert.equal(html, `<root>${config.html}</root>`);
assert.equal(html, config.html);
}
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 '')
const remaining = serialize(target);
assert.equal(
remaining,
'<root></root>',
'Expected component to leave nothing behind after unmount'
);
assert.equal(remaining, '', 'Expected component to leave nothing behind after unmount');
}
} catch (err) {
if (config.runtime_error) {

Loading…
Cancel
Save