Skip to content

Commit d673069

Browse files
committed
test
1 parent b36329a commit d673069

File tree

3 files changed

+87
-0
lines changed

3 files changed

+87
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { flushSync } from 'svelte';
2+
import { test } from '../../test';
3+
4+
export default test({
5+
test({ assert, target }) {
6+
assert.htmlEqual(
7+
target.innerHTML,
8+
`
9+
<button>reset</button>
10+
<div><button>update</button> foo bar baz buz</div>
11+
<div><button>update</button> foo bar baz buz</div>
12+
`
13+
);
14+
15+
const [btn1, btn2, btn3] = target.querySelectorAll('button');
16+
17+
btn2.click();
18+
btn3.click();
19+
flushSync();
20+
assert.htmlEqual(
21+
target.innerHTML,
22+
`
23+
<button>reset</button>
24+
<div><button>update</button> 1 2 3 4</div>
25+
<div><button>update</button> 1 2 3 4</div>
26+
`
27+
);
28+
29+
btn1.click();
30+
flushSync();
31+
assert.htmlEqual(
32+
target.innerHTML,
33+
`
34+
<button>reset</button>
35+
<div><button>update</button> foo bar baz buz</div>
36+
<div><button>update</button> foo bar baz buz</div>
37+
`
38+
);
39+
}
40+
});
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<script>
2+
let { foo, bar = 'bar', baz = $bindable(), buz = $bindable('buz') } = $props();
3+
</script>
4+
5+
<button
6+
onclick={() => {
7+
foo = '1';
8+
bar = '2';
9+
baz = '3';
10+
buz = '4';
11+
}}>update</button
12+
>
13+
14+
{foo}
15+
{bar}
16+
{baz}
17+
{buz}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<script>
2+
import { createClassComponent } from 'svelte/legacy';
3+
import Component from './component.svelte';
4+
import { mount, onMount } from 'svelte';
5+
6+
let div1, div2;
7+
let legacy;
8+
const props = $state({ foo: 'foo', baz: 'baz' });
9+
10+
onMount(() => {
11+
legacy = createClassComponent({
12+
component: Component,
13+
target: div1,
14+
props: { foo: 'foo', baz: 'baz' }
15+
});
16+
mount(Component, { target: div2, props });
17+
});
18+
</script>
19+
20+
<button
21+
onclick={() => {
22+
legacy.$set({ foo: 'foo', bar: 'bar', baz: 'baz', buz: 'buz' });
23+
props.foo = 'foo';
24+
props.bar = 'bar';
25+
props.baz = 'baz';
26+
props.buz = 'buz';
27+
}}>reset</button
28+
>
29+
<div bind:this={div1}></div>
30+
<div bind:this={div2}></div>

0 commit comments

Comments
 (0)