From 81f066fb8950a740eb7c0a7a94f62a6c0efc7047 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sat, 19 Apr 2025 12:18:52 -0400 Subject: [PATCH] update test --- .../samples/async-attribute/_config.js | 40 +++++++++---------- .../samples/async-attribute/main.svelte | 8 +++- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/packages/svelte/tests/runtime-runes/samples/async-attribute/_config.js b/packages/svelte/tests/runtime-runes/samples/async-attribute/_config.js index 2312d8ae60..0c77424e4e 100644 --- a/packages/svelte/tests/runtime-runes/samples/async-attribute/_config.js +++ b/packages/svelte/tests/runtime-runes/samples/async-attribute/_config.js @@ -1,37 +1,33 @@ import { flushSync, tick } from 'svelte'; -import { deferred } from '../../../../src/internal/shared/utils.js'; -import { test } from '../../test'; - -/** @type {ReturnType} */ -let d; +import { ok, test } from '../../test'; export default test({ - html: `

pending

`, - - get props() { - d = deferred(); - - return { - promise: d.promise - }; - }, + html: ` + + + +

pending

+ `, async test({ assert, target, component }) { - d.resolve('cool'); + const [cool, neat, reset] = target.querySelectorAll('button'); + + flushSync(() => cool.click()); await Promise.resolve(); await Promise.resolve(); await Promise.resolve(); await tick(); flushSync(); - assert.htmlEqual(target.innerHTML, '

hello

'); - d = deferred(); - component.promise = d.promise; - await tick(); - assert.htmlEqual(target.innerHTML, '

hello

'); + const p = target.querySelector('p'); + ok(p); + assert.htmlEqual(p.outerHTML, '

hello

'); + + flushSync(() => reset.click()); + assert.htmlEqual(p.outerHTML, '

hello

'); - d.resolve('neat'); + flushSync(() => neat.click()); await tick(); - assert.htmlEqual(target.innerHTML, '

hello

'); + assert.htmlEqual(p.outerHTML, '

hello

'); } }); diff --git a/packages/svelte/tests/runtime-runes/samples/async-attribute/main.svelte b/packages/svelte/tests/runtime-runes/samples/async-attribute/main.svelte index aded514453..6332a9802d 100644 --- a/packages/svelte/tests/runtime-runes/samples/async-attribute/main.svelte +++ b/packages/svelte/tests/runtime-runes/samples/async-attribute/main.svelte @@ -1,9 +1,13 @@ + + + + -

hello

+

hello

{#snippet pending()}

pending