Skip to content

Commit

Permalink
feat: add test for onDestroy call with transition nested component(sv…
Browse files Browse the repository at this point in the history
  • Loading branch information
seo-rii committed Oct 22, 2022
1 parent 146e7a6 commit 5c494f0
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/runtime/samples/transition-js-outro/Inner.svelte
@@ -0,0 +1,8 @@
<script>
import { onDestroy, createEventDispatcher } from 'svelte';
const dispatch = createEventDispatcher();
onDestroy(() => dispatch('destroyed'));
</script>

<div></div>
8 changes: 8 additions & 0 deletions test/runtime/samples/transition-js-outro/_config.js
@@ -0,0 +1,8 @@
export default {
test({ assert, component, raf }) {
component.visible = false;

raf.tick(50);
assert.equal(component.destroyed, true);
}
};
24 changes: 24 additions & 0 deletions test/runtime/samples/transition-js-outro/main.svelte
@@ -0,0 +1,24 @@
<script>
import Inner from './Inner.svelte';
export let visible = true, destroyed = false;
function foo(node) {
return {
duration: 100,
tick: t => {
node.foo = t;
}
};
}
const onDestroy = () => {
destroyed = true;
};
</script>

{#if visible}
<div transition:foo>
<Inner on:destroyed={onDestroy}/>
</div>
{/if}

0 comments on commit 5c494f0

Please sign in to comment.