mirror of https://github.com/sveltejs/svelte
expose add_render_callback as afterFlush - fixes #1976
parent
88004904e1
commit
097507796d
@ -0,0 +1,20 @@
|
|||||||
|
export default {
|
||||||
|
async test({ assert, component, target, window }) {
|
||||||
|
const button = target.querySelector('button');
|
||||||
|
const click = new window.MouseEvent('click');
|
||||||
|
|
||||||
|
await button.dispatchEvent(click);
|
||||||
|
assert.deepEqual(component.snapshots, [
|
||||||
|
'before 0',
|
||||||
|
'after 1'
|
||||||
|
]);
|
||||||
|
|
||||||
|
await button.dispatchEvent(click);
|
||||||
|
assert.deepEqual(component.snapshots, [
|
||||||
|
'before 0',
|
||||||
|
'after 1',
|
||||||
|
'before 1',
|
||||||
|
'after 2'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,19 @@
|
|||||||
|
<script>
|
||||||
|
import { afterFlush } from 'svelte';
|
||||||
|
|
||||||
|
export let snapshots = [];
|
||||||
|
|
||||||
|
let count = 0;
|
||||||
|
let button;
|
||||||
|
|
||||||
|
function click() {
|
||||||
|
count += 1;
|
||||||
|
snapshots.push(`before ${button.textContent}`);
|
||||||
|
|
||||||
|
afterFlush(() => {
|
||||||
|
snapshots.push(`after ${button.textContent}`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<button bind:this={button} on:click={click}>{count}</button>
|
Loading…
Reference in new issue