failing test

pull/16197/head
Rich Harris 7 months ago
parent f30fd267bf
commit 6eac199514

@ -0,0 +1,74 @@
import { flushSync, tick } from 'svelte';
import { ok, test } from '../../test';
export default test({
html: `
<button>shift</button>
<p>loading</p>
`,
async test({ assert, target, variant }) {
if (variant === 'hydrate') {
await Promise.resolve();
}
flushSync(() => {
target.querySelector('button')?.click();
});
await Promise.resolve();
await Promise.resolve();
await Promise.resolve();
await tick();
flushSync();
const [button1, button2] = target.querySelectorAll('button');
assert.htmlEqual(
target.innerHTML,
`
<button>shift</button>
<button>+</button>
<p>A</p>
<p>a</p>
`
);
flushSync(() => button2.click());
flushSync(() => button2.click());
flushSync(() => button1.click());
await Promise.resolve();
await Promise.resolve();
await Promise.resolve();
await tick();
flushSync();
assert.htmlEqual(
target.innerHTML,
`
<button>shift</button>
<button>+</button>
<p>AA</p>
<p>aa</p>
`
);
flushSync(() => button1.click());
await Promise.resolve();
await Promise.resolve();
await Promise.resolve();
await tick();
flushSync();
assert.htmlEqual(
target.innerHTML,
`
<button>shift</button>
<button>+</button>
<p>AAA</p>
<p>aaa</p>
`
);
}
});

@ -0,0 +1,26 @@
<script>
let input = $state('a');
let queue = [];
function push(value) {
const deferred = Promise.withResolvers();
queue.push(() => deferred.resolve(value));
return deferred.promise;
}
</script>
<button onclick={() => queue.shift()()}>shift</button>
<svelte:boundary>
<button onclick={() => input += 'a'}>+</button>
<p>{await push(input.toUpperCase())}</p>
{#if true}
<p>{input}</p>
{/if}
{#snippet pending()}
<p>loading</p>
{/snippet}
</svelte:boundary>
Loading…
Cancel
Save