Skip to content

Commit 6564171

Browse files
committed
add test
1 parent c8f979b commit 6564171

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<script>
2+
let count = $state(1);
3+
4+
let { squared, cubed } = $derived(await {
5+
squared: count ** 2,
6+
cubed: count ** 3
7+
});
8+
</script>
9+
10+
<button onclick={() => count++}>increment</button>
11+
12+
<p>{count} ** 2 = {squared}</p>
13+
<p>{count} ** 3 = {cubed}</p>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { tick } from 'svelte';
2+
import { test } from '../../test';
3+
4+
export default test({
5+
async test({ assert, target }) {
6+
await tick();
7+
8+
const [increment] = target.querySelectorAll('button');
9+
10+
assert.htmlEqual(
11+
target.innerHTML,
12+
`
13+
<button>increment</button>
14+
<p>1 ** 2 = 1</p>
15+
<p>1 ** 3 = 1</p>
16+
`
17+
);
18+
19+
increment.click();
20+
await tick();
21+
22+
assert.htmlEqual(
23+
target.innerHTML,
24+
`
25+
<button>increment</button>
26+
<p>2 ** 2 = 4</p>
27+
<p>2 ** 3 = 8</p>
28+
`
29+
);
30+
}
31+
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<script>
2+
import Child from './Child.svelte';
3+
</script>
4+
5+
<svelte:boundary>
6+
<Child />
7+
8+
{#snippet pending()}
9+
<p>pending</p>
10+
{/snippet}
11+
</svelte:boundary>

0 commit comments

Comments
 (0)