Skip to content

Commit 4f63f9d

Browse files
committed
add spread to test
1 parent bbeeed4 commit 4f63f9d

File tree

2 files changed

+94
-6
lines changed

2 files changed

+94
-6
lines changed

packages/svelte/tests/runtime-runes/samples/class-directive-mutations/_config.js

Lines changed: 88 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { flushSync } from 'svelte';
1+
import { flushSync, tick } from 'svelte';
22
import { test } from '../../test';
33

44
// This test counts mutations on hydration
@@ -16,7 +16,12 @@ export default test({
1616

1717
html: `
1818
<main id="main" class="browser">
19-
<div class="custom svelte-1cjqok6 foo bar"></div>
19+
<div class="custom svelte-1cjqok6 foo bar" title="a title"></div>
20+
<span class="svelte-1cjqok6 foo bar"></span>
21+
<b class="custom foo bar"></b>
22+
<i class="foo bar"></i>
23+
24+
<div class="custom svelte-1cjqok6 foo bar" title="a title"></div>
2025
<span class="svelte-1cjqok6 foo bar"></span>
2126
<b class="custom foo bar"></b>
2227
<i class="foo bar"></i>
@@ -25,19 +30,97 @@ export default test({
2530

2631
ssrHtml: `
2732
<main id="main">
28-
<div class="custom svelte-1cjqok6 foo bar"></div>
33+
<div class="custom svelte-1cjqok6 foo bar" title="a title"></div>
34+
<span class="svelte-1cjqok6 foo bar"></span>
35+
<b class="custom foo bar"></b>
36+
<i class="foo bar"></i>
37+
38+
<div class="custom svelte-1cjqok6 foo bar" title="a title"></div>
2939
<span class="svelte-1cjqok6 foo bar"></span>
3040
<b class="custom foo bar"></b>
3141
<i class="foo bar"></i>
3242
</main>
3343
`,
3444

35-
async test({ assert, component, instance }) {
45+
async test({ target, assert, component, instance }) {
3646
flushSync();
47+
tick();
3748
assert.deepEqual(instance.get_and_clear_mutations(), ['MAIN']);
3849

3950
component.foo = false;
4051
flushSync();
41-
assert.deepEqual(instance.get_and_clear_mutations(), ['DIV', 'SPAN', 'B', 'I']);
52+
tick();
53+
assert.deepEqual(
54+
instance.get_and_clear_mutations(),
55+
['DIV', 'SPAN', 'B', 'I', 'DIV', 'SPAN', 'B', 'I'],
56+
'first mutation'
57+
);
58+
59+
assert.htmlEqual(
60+
target.innerHTML,
61+
`
62+
<main id="main" class="browser">
63+
<div class="custom svelte-1cjqok6 bar" title="a title"></div>
64+
<span class="svelte-1cjqok6 bar"></span>
65+
<b class="custom bar"></b>
66+
<i class="bar"></i>
67+
68+
<div class="custom svelte-1cjqok6 bar" title="a title"></div>
69+
<span class="svelte-1cjqok6 bar"></span>
70+
<b class="custom bar"></b>
71+
<i class="bar"></i>
72+
</main>
73+
`
74+
);
75+
76+
component.foo = true;
77+
flushSync();
78+
assert.deepEqual(
79+
instance.get_and_clear_mutations(),
80+
['DIV', 'SPAN', 'B', 'I', 'DIV', 'SPAN', 'B', 'I'],
81+
'second mutation'
82+
);
83+
84+
assert.htmlEqual(
85+
target.innerHTML,
86+
`
87+
<main id="main" class="browser">
88+
<div class="custom svelte-1cjqok6 bar foo" title="a title"></div>
89+
<span class="svelte-1cjqok6 bar foo"></span>
90+
<b class="custom bar foo"></b>
91+
<i class="bar foo"></i>
92+
93+
<div class="custom svelte-1cjqok6 bar foo" title="a title"></div>
94+
<span class="svelte-1cjqok6 bar foo"></span>
95+
<b class="custom bar foo"></b>
96+
<i class="bar foo"></i>
97+
</main>
98+
`
99+
);
100+
101+
component.classname = 'another';
102+
flushSync();
103+
assert.deepEqual(
104+
instance.get_and_clear_mutations(),
105+
['DIV', 'B', 'DIV', 'B'],
106+
'class mutation'
107+
);
108+
109+
assert.htmlEqual(
110+
target.innerHTML,
111+
`
112+
<main id="main" class="browser">
113+
<div class="another svelte-1cjqok6 foo bar" title="a title"></div>
114+
<span class="svelte-1cjqok6 bar foo"></span>
115+
<b class="another foo bar"></b>
116+
<i class="bar foo"></i>
117+
118+
<div class="another svelte-1cjqok6 foo bar" title="a title"></div>
119+
<span class="svelte-1cjqok6 bar foo"></span>
120+
<b class="another foo bar"></b>
121+
<i class="bar foo"></i>
122+
</main>
123+
`
124+
);
42125
}
43126
});

packages/svelte/tests/runtime-runes/samples/class-directive-mutations/main.svelte

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,15 @@
3333
</script>
3434

3535
<main id="main" class:browser>
36-
<div class={classname} class:foo class:bar></div>
36+
<div class={classname} title="a title" class:foo class:bar></div>
3737
<span class:foo class:bar></span>
3838
<b class={classname} class:foo class:bar></b>
3939
<i class:foo class:bar></i>
40+
41+
<div {...{class:classname, title:"a title"}} class:foo class:bar></div>
42+
<span {...{}} class:foo class:bar></span>
43+
<b {...{class:classname}} class:foo class:bar></b>
44+
<i {...{}} class:foo class:bar></i>
4045
</main>
4146

4247
<style>

0 commit comments

Comments
 (0)