Skip to content

Commit

Permalink
test template with text content
Browse files Browse the repository at this point in the history
  • Loading branch information
lidlanca committed Feb 26, 2022
1 parent 257732e commit babadec
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
17 changes: 12 additions & 5 deletions test/runtime/samples/template/_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,23 @@ export default {
`,

test({ assert, target }) {
const template = target.querySelector('template');


const template = target.querySelector('#t1');
assert.htmlEqual(template.innerHTML, `
<div>foo</div>
`);

<div>foo</div>
`);
const content = template.content.cloneNode(true);
const div = content.children[0];
assert.htmlEqual(div.outerHTML, `
<div>foo</div>
`);


const template2 = target.querySelector('#t2');
assert.equal(template2.childNodes.length, 0);
assert.equal(template2.content.childNodes.length, 1);
assert.equal(template2.content.firstChild.textContent, '123');
assert.htmlEqual(template2.innerHTML, '123');

}
};
5 changes: 3 additions & 2 deletions test/runtime/samples/template/main.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<template>
<template id="t1">
<div>foo</div>
</template>
</template>
<template id="t2">123</template>

0 comments on commit babadec

Please sign in to comment.