Skip to content

Commit 0934e36

Browse files
committed
add test
1 parent 9d7b9d6 commit 0934e36

File tree

3 files changed

+85
-0
lines changed

3 files changed

+85
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<script>
2+
let id = $props.id();
3+
</script>
4+
5+
<p>{id}</p>
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import { flushSync } from 'svelte';
2+
import { test } from '../../test';
3+
4+
export default test({
5+
test({ assert, target, variant }) {
6+
if (variant === 'dom') {
7+
assert.htmlEqual(
8+
target.innerHTML,
9+
`
10+
<button>toggle</button>
11+
<h1>c1</h1>
12+
<p>c2</p>
13+
<p>c3</p>
14+
<p>c4</p>
15+
`
16+
);
17+
} else {
18+
assert.htmlEqual(
19+
target.innerHTML,
20+
`
21+
<button>toggle</button>
22+
<h1>s1</h1>
23+
<p>s2</p>
24+
<p>s3</p>
25+
<p>s4</p>
26+
`
27+
);
28+
}
29+
30+
let button = target.querySelector('button');
31+
flushSync(() => button?.click());
32+
33+
if (variant === 'dom') {
34+
assert.htmlEqual(
35+
target.innerHTML,
36+
`
37+
<button>toggle</button>
38+
<h1>c1</h1>
39+
<p>c2</p>
40+
<p>c3</p>
41+
<p>c4</p>
42+
<p>c5</p>
43+
`
44+
);
45+
} else {
46+
// `c6` because this runs after the `dom` tests
47+
// (slightly brittle but good enough for now)
48+
assert.htmlEqual(
49+
target.innerHTML,
50+
`
51+
<button>toggle</button>
52+
<h1>s1</h1>
53+
<p>s2</p>
54+
<p>s3</p>
55+
<p>s4</p>
56+
<p>c6</p>
57+
`
58+
);
59+
}
60+
}
61+
});
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<script>
2+
import Child from './Child.svelte';
3+
4+
let id = $props.id();
5+
6+
let show = $state(false);
7+
</script>
8+
9+
<button onclick={() => show = !show}>toggle</button>
10+
11+
<h1>{id}</h1>
12+
13+
<Child />
14+
<Child />
15+
<Child />
16+
17+
{#if show}
18+
<Child />
19+
{/if}

0 commit comments

Comments
 (0)