mirror of https://github.com/sveltejs/svelte
parent
3cf0b9e077
commit
302dff234b
@ -0,0 +1,59 @@
|
|||||||
|
import { flushSync, settled, tick } from 'svelte';
|
||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
export default test({
|
||||||
|
html: `<p>loading...</p>`,
|
||||||
|
|
||||||
|
async test({ assert, target }) {
|
||||||
|
await Promise.resolve();
|
||||||
|
await Promise.resolve();
|
||||||
|
await Promise.resolve();
|
||||||
|
await Promise.resolve();
|
||||||
|
|
||||||
|
assert.htmlEqual(
|
||||||
|
target.innerHTML,
|
||||||
|
`
|
||||||
|
<button>log</button>
|
||||||
|
<button>x 1</button>
|
||||||
|
<button>other 1</button>
|
||||||
|
<p>1</p>
|
||||||
|
<p>1</p>
|
||||||
|
<p>1</p>
|
||||||
|
`
|
||||||
|
);
|
||||||
|
|
||||||
|
const [log, x, other] = target.querySelectorAll('button');
|
||||||
|
|
||||||
|
flushSync(() => x.click());
|
||||||
|
flushSync(() => other.click());
|
||||||
|
|
||||||
|
assert.htmlEqual(
|
||||||
|
target.innerHTML,
|
||||||
|
`
|
||||||
|
<button>log</button>
|
||||||
|
<button>x 1</button>
|
||||||
|
<button>other 2</button>
|
||||||
|
<p>1</p>
|
||||||
|
<p>1</p>
|
||||||
|
<p>1</p>
|
||||||
|
`
|
||||||
|
);
|
||||||
|
|
||||||
|
await Promise.resolve();
|
||||||
|
await Promise.resolve();
|
||||||
|
await Promise.resolve();
|
||||||
|
await Promise.resolve();
|
||||||
|
|
||||||
|
assert.htmlEqual(
|
||||||
|
target.innerHTML,
|
||||||
|
`
|
||||||
|
<button>log</button>
|
||||||
|
<button>x 2</button>
|
||||||
|
<button>other 2</button>
|
||||||
|
<p>2</p>
|
||||||
|
<p>2</p>
|
||||||
|
<p>2</p>
|
||||||
|
`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
@ -0,0 +1,19 @@
|
|||||||
|
<script>
|
||||||
|
let x = $state(1);
|
||||||
|
let y = $derived(x);
|
||||||
|
let other = $state(1);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<svelte:boundary>
|
||||||
|
<button onclick={() => console.log({ x, y })}>log</button>
|
||||||
|
<button onclick={() => x += 1}>x {x}</button>
|
||||||
|
<button onclick={() => other += 1}>other {other}</button>
|
||||||
|
|
||||||
|
<p>{x}</p>
|
||||||
|
<p>{await x}</p>
|
||||||
|
<p>{y}</p>
|
||||||
|
|
||||||
|
{#snippet pending()}
|
||||||
|
<p>loading...</p>
|
||||||
|
{/snippet}
|
||||||
|
</svelte:boundary>
|
Loading…
Reference in new issue