Skip to content

Commit d0d9a36

Browse files
committed
chore: add test for agglomerated onchange
1 parent ec77f8b commit d0d9a36

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { flushSync } from 'svelte';
2+
import { test } from '../../test';
3+
4+
export default test({
5+
async test({ assert, target, logs }) {
6+
const [btn, btn2] = target.querySelectorAll('button');
7+
8+
flushSync(() => {
9+
btn.click();
10+
});
11+
assert.deepEqual(logs, ['foo', 'baz']);
12+
13+
flushSync(() => {
14+
btn2.click();
15+
});
16+
assert.deepEqual(logs, ['foo', 'baz', 'foo', 'baz']);
17+
}
18+
});
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<script>
2+
let foo = $state({ bar: 1 }, {
3+
onchange(){
4+
console.log("foo");
5+
}
6+
});
7+
let baz = $state(foo, {
8+
onchange(){
9+
console.log("baz");
10+
}
11+
})
12+
</script>
13+
14+
<button onclick={()=> foo.bar++}>foo</button>
15+
<button onclick={()=> baz.bar++}>baz</button>

0 commit comments

Comments
 (0)