mirror of https://github.com/sveltejs/svelte
parent
e57a97b2af
commit
3d6cd65d94
@ -0,0 +1,8 @@
|
||||
|
||||
<script>
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
onMount(() => {
|
||||
return () => console.log('destroy');
|
||||
});
|
||||
</script>
|
||||
@ -0,0 +1,17 @@
|
||||
export default {
|
||||
html: `
|
||||
<button>destroy component</button>
|
||||
`,
|
||||
|
||||
async test({ assert, target, window }) {
|
||||
const button = target.querySelector('button');
|
||||
const event = new window.MouseEvent('click');
|
||||
const messages = [];
|
||||
console.log = msg => messages.push(msg);
|
||||
await button.dispatchEvent(event);
|
||||
assert.htmlEqual(target.innerHTML, `
|
||||
<button>destroy component</button>
|
||||
`);
|
||||
assert.deepEqual(messages, ['destroy']);
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,8 @@
|
||||
<script>
|
||||
import Empty from './Empty.svelte';
|
||||
let active = true;
|
||||
</script>
|
||||
|
||||
<button on:click='{() => active = false }'>destroy component</button>
|
||||
|
||||
<svelte:component this={active ? Empty : null} />
|
||||
Loading…
Reference in new issue