mirror of https://github.com/sveltejs/svelte
parent
9960780c30
commit
e6eb10c581
@ -0,0 +1,28 @@
|
|||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
foo: 0,
|
||||||
|
bar: 0
|
||||||
|
},
|
||||||
|
|
||||||
|
html: `
|
||||||
|
<button>click me</button>
|
||||||
|
<p>foo: 0</p>
|
||||||
|
<p>bar: 0</p>
|
||||||
|
`,
|
||||||
|
|
||||||
|
async test({ assert, component, target, window }) {
|
||||||
|
const button = target.querySelector('button');
|
||||||
|
const click = new window.MouseEvent('click');
|
||||||
|
|
||||||
|
await button.dispatchEvent(click);
|
||||||
|
|
||||||
|
assert.equal(component.foo, 4);
|
||||||
|
assert.equal(component.bar, 2);
|
||||||
|
|
||||||
|
assert.htmlEqual(target.innerHTML, `
|
||||||
|
<button>click me</button>
|
||||||
|
<p>foo: 4</p>
|
||||||
|
<p>bar: 2</p>
|
||||||
|
`);
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,12 @@
|
|||||||
|
<script>
|
||||||
|
export let foo, bar;
|
||||||
|
|
||||||
|
function click() {
|
||||||
|
foo = 4; bar = 2;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<button on:click={click}>click me</button>
|
||||||
|
|
||||||
|
<p>foo: {foo}</p>
|
||||||
|
<p>bar: {bar}</p>
|
@ -0,0 +1,28 @@
|
|||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
foo: 0,
|
||||||
|
bar: 0
|
||||||
|
},
|
||||||
|
|
||||||
|
html: `
|
||||||
|
<button>click me</button>
|
||||||
|
<p>foo: 0</p>
|
||||||
|
<p>bar: 0</p>
|
||||||
|
`,
|
||||||
|
|
||||||
|
async test({ assert, component, target, window }) {
|
||||||
|
const button = target.querySelector('button');
|
||||||
|
const click = new window.MouseEvent('click');
|
||||||
|
|
||||||
|
await button.dispatchEvent(click);
|
||||||
|
|
||||||
|
assert.equal(component.foo, 4);
|
||||||
|
assert.equal(component.bar, 2);
|
||||||
|
|
||||||
|
assert.htmlEqual(target.innerHTML, `
|
||||||
|
<button>click me</button>
|
||||||
|
<p>foo: 4</p>
|
||||||
|
<p>bar: 2</p>
|
||||||
|
`);
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,8 @@
|
|||||||
|
<script>
|
||||||
|
export let foo, bar;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<button on:click="{() => { foo = 4; bar = 2; }}">click me</button>
|
||||||
|
|
||||||
|
<p>foo: {foo}</p>
|
||||||
|
<p>bar: {bar}</p>
|
Loading…
Reference in new issue