Skip to content

Commit c69c5d7

Browse files
committed
beef up test
1 parent bd0157a commit c69c5d7

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed
Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
1+
import { flushSync } from 'svelte';
12
import { test } from '../../test';
23

34
export default test({
4-
ssrHtml: `<div></div>`,
5-
html: `<div>set from component</div>`
5+
html: `<button>update</button><div></div>`,
6+
7+
test({ target, assert, logs }) {
8+
const button = target.querySelector('button');
9+
10+
assert.deepEqual(logs, ['one DIV']);
11+
12+
flushSync(() => button?.click());
13+
assert.deepEqual(logs, ['one DIV', 'cleanup one', 'two DIV']);
14+
}
615
});

packages/svelte/tests/runtime-runes/samples/attachment-component-spread/main.svelte

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,28 @@
33
import Child from './Child.svelte';
44
55
let stuff = $state({
6-
[createAttachmentKey()]: (node) => node.textContent = 'set from component'
6+
[createAttachmentKey()]: (node) => {
7+
console.log(`one ${node.nodeName}`);
8+
9+
return () => {
10+
console.log('cleanup one');
11+
};
12+
}
713
});
14+
15+
function update() {
16+
stuff = {
17+
[createAttachmentKey()]: (node) => {
18+
console.log(`two ${node.nodeName}`);
19+
20+
return () => {
21+
console.log('cleanup two');
22+
}
23+
}
24+
};
25+
}
826
</script>
927

28+
<button onclick={update}>update</button>
29+
1030
<Child {...stuff} />

0 commit comments

Comments
 (0)