mirror of https://github.com/sveltejs/svelte
parent
cf63220a0e
commit
ffa28666f6
@ -0,0 +1,7 @@
|
||||
<script>
|
||||
const {count, increment} = $props();
|
||||
</script>
|
||||
|
||||
<button onclick={increment}>
|
||||
{count}
|
||||
</button>
|
||||
@ -0,0 +1,15 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
html: '<button>0</button>',
|
||||
|
||||
async test({ assert, target, component }) {
|
||||
const [btn] = target.querySelectorAll('button');
|
||||
flushSync(() => {
|
||||
btn.click();
|
||||
});
|
||||
assert.deepEqual(component.log, ['beforeUpdate', 'afterUpdate']);
|
||||
assert.htmlEqual(target.innerHTML, `<button>1</button>`);
|
||||
}
|
||||
});
|
||||
@ -0,0 +1,22 @@
|
||||
<script>
|
||||
import Child from './Child.svelte'
|
||||
import {afterUpdate, beforeUpdate} from 'svelte';
|
||||
|
||||
const {log = []} = $props();
|
||||
|
||||
let count = $state(0);
|
||||
|
||||
const increment = () => {
|
||||
count++;
|
||||
}
|
||||
|
||||
beforeUpdate(() => {
|
||||
log.push('beforeUpdate');
|
||||
});
|
||||
|
||||
afterUpdate(() => {
|
||||
log.push('afterUpdate');
|
||||
});
|
||||
</script>
|
||||
|
||||
<Child count={count} increment={increment} />
|
||||
Loading…
Reference in new issue