Skip to content

Commit 4be5488

Browse files
committed
add test
1 parent 312d2b6 commit 4be5488

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

packages/svelte/tests/runtime-runes/samples/async-reactivity-loss/_config.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@ export default test({
66
dev: true
77
},
88

9-
html: `<button>a</button><button>b</button><p>pending</p>`,
9+
html: `<button>a</button><button>b</button><button>c</button><p>pending</p>`,
1010

1111
async test({ assert, target, warnings }) {
1212
await tick();
13-
assert.htmlEqual(target.innerHTML, '<button>a</button><button>b</button><h1>3</h1><p>3</p>');
13+
assert.htmlEqual(
14+
target.innerHTML,
15+
'<button>a</button><button>b</button><button>c</button><h1>6</h1><p>6</p>'
16+
);
1417

1518
assert.equal(
1619
warnings[0],

packages/svelte/tests/runtime-runes/samples/async-reactivity-loss/main.svelte

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
<script>
2+
import { untrack } from 'svelte';
23
let a = $state(1);
34
let b = $state(2);
5+
let c = $state(3);
46
5-
async function a_plus_b() {
6-
return await a + await b;
7+
async function a_plus_b_plus_c() {
8+
return await a + await b + await untrack(() => c);
79
}
810
</script>
911

1012
<button onclick={() => a++}>a</button>
1113
<button onclick={() => b++}>b</button>
14+
<button onclick={() => c++}>c</button>
1215

1316
<svelte:boundary>
14-
<h1>{await a_plus_b()}</h1>
15-
<p>{await a + await b}</p>
17+
<h1>{await a_plus_b_plus_c()}</h1>
18+
<p>{await a + await b + await c}</p>
1619

1720
{#snippet pending()}
1821
<p>pending</p>

0 commit comments

Comments
 (0)