Skip to content

Commit 507d577

Browse files
committed
add test
1 parent bf9d999 commit 507d577

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<script>
2+
let { object } = $props();
3+
4+
await 1;
5+
</script>
6+
7+
<button onclick={() => object.count++}>clicks: {object.count}</button>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { tick } from 'svelte';
2+
import { test } from '../../test';
3+
4+
export default test({
5+
compileOptions: {
6+
dev: true
7+
},
8+
9+
async test({ assert, target, warnings }) {
10+
await tick();
11+
12+
const [button] = target.querySelectorAll('button');
13+
14+
button.click();
15+
await tick();
16+
17+
assert.htmlEqual(target.innerHTML, '<button>clicks: 1</button>');
18+
assert.deepEqual(warnings, [
19+
'Mutating unbound props (`object`, at Child.svelte:7:23) is strongly discouraged. Consider using `bind:object={...}` in main.svelte (or using a callback) instead'
20+
]);
21+
}
22+
});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<script>
2+
import Child from './Child.svelte';
3+
4+
let object = $state({ count: 0 });
5+
</script>
6+
7+
<svelte:boundary>
8+
<Child {object} />
9+
10+
{#snippet pending()}
11+
<p>loading...</p>
12+
{/snippet}
13+
</svelte:boundary>

0 commit comments

Comments
 (0)