Skip to content

Commit d80f9b1

Browse files
committed
add test
1 parent 69f7ea8 commit d80f9b1

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { test } from '../../test';
2+
import { flushSync } from 'svelte';
3+
4+
export default test({
5+
async test({ assert, target, logs }) {
6+
const [b1] = target.querySelectorAll('button');
7+
flushSync(() => {
8+
b1.click();
9+
});
10+
flushSync(() => {
11+
b1.click();
12+
});
13+
assert.deepEqual(logs, [
14+
'effect',
15+
0,
16+
'in-increment',
17+
1,
18+
'effect',
19+
1,
20+
'in-increment',
21+
2,
22+
'effect',
23+
2
24+
]);
25+
}
26+
});
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<script>
2+
let count = $state(0);
3+
4+
function increment() {
5+
count += 1;
6+
console.log("in-increment", count);
7+
}
8+
9+
$effect(() => {
10+
console.log("effect", count);
11+
});
12+
13+
$inspect(count);
14+
</script>
15+
16+
<button onclick={increment}>
17+
clicks: {count}
18+
</button>

0 commit comments

Comments
 (0)