mirror of https://github.com/sveltejs/svelte
parent
5f020cc91e
commit
55bb1c2714
@ -0,0 +1 @@
|
||||
<slot/>
|
||||
@ -0,0 +1,12 @@
|
||||
<script>
|
||||
import { onMount } from "svelte";
|
||||
|
||||
export let logs;
|
||||
|
||||
onMount(() => {
|
||||
logs.push("mount");
|
||||
return () => {
|
||||
logs.push("unmount");
|
||||
};
|
||||
});
|
||||
</script>
|
||||
@ -0,0 +1,18 @@
|
||||
let logs = [];
|
||||
|
||||
export default {
|
||||
html: "<button>Reset!</button>",
|
||||
props: {
|
||||
logs,
|
||||
},
|
||||
async test({ assert, component, target, raf }) {
|
||||
assert.deepEqual(logs, ["mount"]);
|
||||
|
||||
const button = target.querySelector("button");
|
||||
|
||||
const click = new window.MouseEvent("click");
|
||||
await button.dispatchEvent(click);
|
||||
|
||||
assert.deepEqual(logs, ["mount", "unmount", "mount"]);
|
||||
},
|
||||
};
|
||||
@ -0,0 +1,17 @@
|
||||
<script>
|
||||
import Component1 from './Component1.svelte'
|
||||
import Component2 from './Component2.svelte'
|
||||
|
||||
let reset = false
|
||||
export let logs;
|
||||
</script>
|
||||
|
||||
<Component1>
|
||||
{#key reset}
|
||||
<Component2 {logs} />
|
||||
{/key}
|
||||
</Component1>
|
||||
|
||||
<button on:click={() => reset = !reset}>
|
||||
Reset!
|
||||
</button>
|
||||
Loading…
Reference in new issue