mirror of https://github.com/sveltejs/svelte
add test (#9917)
parent
b1efd8c4cd
commit
2608e621d6
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: cleanup each block animations on destroy
|
@ -0,0 +1,60 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { ok, test } from '../../test';
|
||||
|
||||
export default test({
|
||||
async test({ assert, target, window }) {
|
||||
const button = target.querySelector('button');
|
||||
ok(button);
|
||||
|
||||
assert.htmlEqual(
|
||||
target.innerHTML,
|
||||
`
|
||||
<button>Remove last</button><div class="list"><label><input type="checkbox">
|
||||
write
|
||||
some
|
||||
docs</label><label><input type="checkbox">
|
||||
start
|
||||
writing
|
||||
JSConf
|
||||
talk</label><label><input type="checkbox">
|
||||
buy
|
||||
some
|
||||
milk</label><label><input type="checkbox">
|
||||
mow
|
||||
the
|
||||
lawn</label><label><input type="checkbox">
|
||||
feed
|
||||
the
|
||||
turtle</label><label><input type="checkbox">
|
||||
fix
|
||||
some
|
||||
bugs</label></div>`
|
||||
);
|
||||
|
||||
flushSync(() => {
|
||||
button.click();
|
||||
});
|
||||
|
||||
assert.htmlEqual(
|
||||
target.innerHTML,
|
||||
`
|
||||
<button>Remove last</button><div class="list"><label><input type="checkbox">
|
||||
write
|
||||
some
|
||||
docs</label><label><input type="checkbox">
|
||||
start
|
||||
writing
|
||||
JSConf
|
||||
talk</label><label><input type="checkbox">
|
||||
buy
|
||||
some
|
||||
milk</label><label><input type="checkbox">
|
||||
mow
|
||||
the
|
||||
lawn</label><label><input type="checkbox">
|
||||
feed
|
||||
the
|
||||
turtle</label></div>`
|
||||
);
|
||||
}
|
||||
});
|
@ -0,0 +1,28 @@
|
||||
<script>
|
||||
import { flip } from 'svelte/animate';
|
||||
|
||||
let todos = [
|
||||
{ id: 1, done: false, description: 'write some docs' },
|
||||
{ id: 2, done: false, description: 'start writing JSConf talk' },
|
||||
{ id: 3, done: true, description: 'buy some milk' },
|
||||
{ id: 4, done: false, description: 'mow the lawn' },
|
||||
{ id: 5, done: false, description: 'feed the turtle' },
|
||||
{ id: 6, done: false, description: 'fix some bugs' }
|
||||
];
|
||||
|
||||
function update() {
|
||||
todos = [...todos]
|
||||
todos.pop();
|
||||
}
|
||||
</script>
|
||||
|
||||
<button on:click={update}>Remove last</button>
|
||||
|
||||
<div class="list">
|
||||
{#each todos as todo (todo.id)}
|
||||
<label animate:flip>
|
||||
<input type="checkbox" bind:checked={todo.done} />
|
||||
{todo.description}
|
||||
</label>
|
||||
{/each}
|
||||
</div>
|
Loading…
Reference in new issue