mirror of https://github.com/sveltejs/svelte
parent
d2e79efb90
commit
32caac52c0
@ -0,0 +1,30 @@
|
||||
import { test } from '../../test';
|
||||
import { flushSync } from 'svelte';
|
||||
import { log } from './log.js';
|
||||
|
||||
export default test({
|
||||
before_test() {
|
||||
log.length = 0;
|
||||
},
|
||||
|
||||
async test({ assert, target }) {
|
||||
const [b1] = target.querySelectorAll('button');
|
||||
flushSync(() => {
|
||||
b1.click();
|
||||
});
|
||||
flushSync(() => {
|
||||
b1.click();
|
||||
});
|
||||
assert.deepEqual(log, [
|
||||
{ a: 1 },
|
||||
{ b: 1 },
|
||||
{ c: 1 },
|
||||
{ a: 2 },
|
||||
{ b: 2 },
|
||||
{ c: 2 },
|
||||
{ a: 3 },
|
||||
{ b: 3 },
|
||||
{ c: 3 }
|
||||
]);
|
||||
}
|
||||
});
|
@ -0,0 +1,2 @@
|
||||
/** @type {any[]} */
|
||||
export const log = [];
|
@ -0,0 +1,28 @@
|
||||
<script>
|
||||
import { log } from './log.js';
|
||||
let a = $state(1);
|
||||
let b = $state(1);
|
||||
let c = $state(1);
|
||||
|
||||
$effect(() => {
|
||||
log.push({ a });
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
log.push({ b });
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
log.push({ c });
|
||||
});
|
||||
|
||||
function increment() {
|
||||
b += 1;
|
||||
c += 1;
|
||||
a += 1;
|
||||
}
|
||||
</script>
|
||||
|
||||
<button onclick={increment}>
|
||||
increment
|
||||
</button>
|
Loading…
Reference in new issue