mirror of https://github.com/sveltejs/svelte
parent
9dfc89ecd7
commit
f08f40739c
@ -0,0 +1,17 @@
|
|||||||
|
export default {
|
||||||
|
html: `
|
||||||
|
<button>foo</button>
|
||||||
|
<p>x: 0</p>
|
||||||
|
`,
|
||||||
|
|
||||||
|
async test({ assert, component, target, window }) {
|
||||||
|
const buttons = target.querySelectorAll('button');
|
||||||
|
const click = new window.MouseEvent('click');
|
||||||
|
|
||||||
|
await buttons[0].dispatchEvent(click);
|
||||||
|
assert.htmlEqual(target.innerHTML, `
|
||||||
|
<button>foo</button>
|
||||||
|
<p>x: 42</p>
|
||||||
|
`);
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,14 @@
|
|||||||
|
<script>
|
||||||
|
let x = 0;
|
||||||
|
|
||||||
|
function foo() {
|
||||||
|
(() => {
|
||||||
|
for (let x = 0; x < 10; x++) {}
|
||||||
|
x = 42;
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<button on:click={foo}>foo</button>
|
||||||
|
|
||||||
|
<p>x: {x}</p>
|
@ -0,0 +1,21 @@
|
|||||||
|
export default {
|
||||||
|
html: `
|
||||||
|
<button>foo</button>
|
||||||
|
<button>bar</button>
|
||||||
|
|
||||||
|
<p>x: 0</p>
|
||||||
|
`,
|
||||||
|
|
||||||
|
async test({ assert, component, target, window }) {
|
||||||
|
const buttons = target.querySelectorAll('button');
|
||||||
|
const click = new window.MouseEvent('click');
|
||||||
|
|
||||||
|
await buttons[0].dispatchEvent(click);
|
||||||
|
assert.htmlEqual(target.innerHTML, `
|
||||||
|
<button>foo</button>
|
||||||
|
<button>bar</button>
|
||||||
|
|
||||||
|
<p>x: 42</p>
|
||||||
|
`);
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,12 @@
|
|||||||
|
<script>
|
||||||
|
let x = 0;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<button on:click="{() => {
|
||||||
|
(() => {
|
||||||
|
for (let x = 0; x < 10; x++) {}
|
||||||
|
x = 42;
|
||||||
|
})();
|
||||||
|
}}">foo</button>
|
||||||
|
|
||||||
|
<p>x: {x}</p>
|
Loading…
Reference in new issue