mirror of https://github.com/sveltejs/svelte
parent
f824a2437e
commit
c2e0e98679
@ -0,0 +1,20 @@
|
|||||||
|
const calls = [];
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
calls,
|
||||||
|
},
|
||||||
|
|
||||||
|
async test({ assert, component, target, window }) {
|
||||||
|
const buttons = target.querySelector('button');
|
||||||
|
|
||||||
|
assert.deepEqual(calls.length, 1);
|
||||||
|
|
||||||
|
const event = new window.MouseEvent('click');
|
||||||
|
await buttons.dispatchEvent(event);
|
||||||
|
|
||||||
|
assert.deepEqual(calls.length, 1);
|
||||||
|
|
||||||
|
component.current_path = 'bar';
|
||||||
|
assert.deepEqual(calls.length, 2);
|
||||||
|
},
|
||||||
|
};
|
@ -0,0 +1,17 @@
|
|||||||
|
<script>
|
||||||
|
import { writable } from 'svelte/store';
|
||||||
|
export let current_path = 'foo';
|
||||||
|
export let calls;
|
||||||
|
let i = 0;
|
||||||
|
function getComponent(path) {
|
||||||
|
calls.push(path);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
function onClick() {
|
||||||
|
i = i + 1;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<svelte:component this={getComponent(current_path)} />
|
||||||
|
<button on:click={onClick}>click me</button>
|
||||||
|
{ i }
|
Loading…
Reference in new issue