mirror of https://github.com/sveltejs/svelte
Co-authored-by: Marcin Wicha <23581770+marcin-wicha@users.noreply.github.com>pull/8341/head
parent
dc36d0c9af
commit
34c9ad74c3
@ -0,0 +1,17 @@
|
|||||||
|
export default {
|
||||||
|
async test({ assert, component, target, window }) {
|
||||||
|
const button = target.querySelector('button');
|
||||||
|
const event = new window.MouseEvent('click');
|
||||||
|
|
||||||
|
await button.dispatchEvent(event);
|
||||||
|
assert.deepEqual(component.logs, ['click_1', 'click_2']);
|
||||||
|
|
||||||
|
component.click_2 = () => component.logs.push('22');
|
||||||
|
await button.dispatchEvent(event);
|
||||||
|
assert.deepEqual(component.logs, ['click_1', 'click_2', 'click_1', '22']);
|
||||||
|
|
||||||
|
component.click_1 = () => component.logs.push('11');
|
||||||
|
await button.dispatchEvent(event);
|
||||||
|
assert.deepEqual(component.logs, ['click_1', 'click_2', 'click_1', '22', '11', '22']);
|
||||||
|
}
|
||||||
|
};
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
<script>
|
||||||
|
export let logs = [];
|
||||||
|
|
||||||
|
export let click_1 = () => {
|
||||||
|
logs.push('click_1');
|
||||||
|
}
|
||||||
|
|
||||||
|
export let click_2 = () => {
|
||||||
|
logs.push('click_2');
|
||||||
|
}
|
||||||
|
|
||||||
|
export let click_3 = () => {
|
||||||
|
logs.push('click_3');
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<button
|
||||||
|
on:click={click_1}
|
||||||
|
on:click|stopImmediatePropagation={click_2}
|
||||||
|
on:click={click_3}>
|
||||||
|
click me
|
||||||
|
</button>
|
||||||
Loading…
Reference in new issue