Skip to content

Commit 350ec9f

Browse files
committed
test: add more guard-derived regression samples
1 parent a22bfe2 commit 350ec9f

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { test } from '../../test';
2+
import { flushSync } from 'svelte';
3+
4+
export default test({
5+
mode: ['client'],
6+
async test({ target }) {
7+
const button = target.querySelector('button');
8+
9+
flushSync(() => button?.click());
10+
11+
const text = target.textContent?.trim() ?? '';
12+
if (!text.endsWith('advance')) {
13+
throw new Error(`unexpected text: ${text}`);
14+
}
15+
}
16+
});
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<script>
2+
import Wrapper from './wrapper.svelte';
3+
4+
let rows = $state([
5+
{ nested: { depth: 1 } },
6+
{ nested: { depth: 3 } }
7+
]);
8+
let ptr = $state(0);
9+
10+
let current = $derived(rows[ptr]);
11+
let currentLength = $derived(current?.length);
12+
let nested = $derived(current?.nested);
13+
14+
$effect(() => {
15+
if (ptr === 1) {
16+
rows = [];
17+
}
18+
});
19+
</script>
20+
21+
<Wrapper>
22+
{#if currentLength && nested?.depth > 2}
23+
deep
24+
{:else}
25+
shallow
26+
{/if}
27+
</Wrapper>
28+
29+
<div>
30+
{#if nested?.depth > 2}
31+
deep
32+
{:else}
33+
shallow
34+
{/if}
35+
</div>
36+
37+
<button onclick={() => (ptr = 1)}>advance</button>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<script>
2+
let { children } = $props();
3+
</script>
4+
5+
{@render children()}

0 commit comments

Comments
 (0)