mirror of https://github.com/sveltejs/svelte
parent
feafc34f8e
commit
58b7b5b325
@ -0,0 +1,20 @@
|
||||
export default {
|
||||
html: `<button>bar</button>`,
|
||||
|
||||
async test({ assert, component, target, window }) {
|
||||
const [button] = target.querySelectorAll(
|
||||
'button'
|
||||
);
|
||||
|
||||
const event = new window.MouseEvent('click');
|
||||
|
||||
await button.dispatchEvent(event);
|
||||
assert.htmlEqual(target.innerHTML, `<button>foo</button>`);
|
||||
|
||||
await button.dispatchEvent(event);
|
||||
assert.htmlEqual(target.innerHTML, `<button>bar</button>`);
|
||||
|
||||
await button.dispatchEvent(event);
|
||||
assert.htmlEqual(target.innerHTML, `<button>foo</button>`);
|
||||
},
|
||||
};
|
@ -0,0 +1,12 @@
|
||||
<script>
|
||||
let name = 'bar';
|
||||
function foo() {
|
||||
name = 'foo';
|
||||
}
|
||||
function bar() {
|
||||
name = 'bar';
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<button on:click={name === 'bar' ? foo : bar}>{name}</button>
|
Loading…
Reference in new issue