add test sample

pull/17363/head
David Roizenman 6 days ago
parent 435da13fdd
commit 2cd6ddf9eb
No known key found for this signature in database
GPG Key ID: CD7B405D13E241B6

@ -0,0 +1,10 @@
<script>
class Y {
foo = $state(0);
}
let y = $derived(new Y());
</script>
<button onclick={() => y.foo++}>click</button>
<p>{y.foo}</p>

@ -0,0 +1,24 @@
import { flushSync } from 'svelte';
import { test } from '../../test';
export default test({
skip_no_async: true,
async test({ assert, target }) {
const forkButton = target.querySelector('button');
flushSync(() => {
forkButton?.click();
});
const [, clickButton] = target.querySelectorAll('button');
const p = target.querySelector('p');
assert.equal(p?.textContent, '0');
flushSync(() => {
clickButton?.click();
});
assert.equal(p?.textContent, '1');
}
});

@ -0,0 +1,17 @@
<script>
import { fork } from 'svelte';
import Child from './Child.svelte';
let x = $state(false);
</script>
<button onclick={() => {
const f = fork(() => {
x = true;
});
f.commit();
}}>fork</button>
{#if x}
<Child />
{/if}
Loading…
Cancel
Save