You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
svelte/packages/svelte/tests/runtime-runes/samples/async-attribute/_config.js

35 lines
807 B

import { flushSync, tick } from 'svelte';
import { ok, test } from '../../test';
export default test({
html: `
<button>cool</button>
<button>neat</button>
<button>reset</button>
<p>pending</p>
`,
async test({ assert, target }) {
const [cool, neat, reset] = target.querySelectorAll('button');
flushSync(() => cool.click());
await Promise.resolve();
await Promise.resolve();
await Promise.resolve();
await tick();
flushSync();
const p = target.querySelector('p');
ok(p);
assert.htmlEqual(p.outerHTML, '<p class="cool">hello</p>');
flushSync(() => reset.click());
assert.htmlEqual(p.outerHTML, '<p class="cool">hello</p>');
flushSync(() => neat.click());
await Promise.resolve();
await tick();
assert.htmlEqual(p.outerHTML, '<p class="neat">hello</p>');
}
});