mirror of https://github.com/sveltejs/svelte
parent
8b691e9ea2
commit
81f066fb89
@ -1,37 +1,33 @@
|
|||||||
import { flushSync, tick } from 'svelte';
|
import { flushSync, tick } from 'svelte';
|
||||||
import { deferred } from '../../../../src/internal/shared/utils.js';
|
import { ok, test } from '../../test';
|
||||||
import { test } from '../../test';
|
|
||||||
|
|
||||||
/** @type {ReturnType<typeof deferred>} */
|
|
||||||
let d;
|
|
||||||
|
|
||||||
export default test({
|
export default test({
|
||||||
html: `<p>pending</p>`,
|
html: `
|
||||||
|
<button>cool</button>
|
||||||
get props() {
|
<button>neat</button>
|
||||||
d = deferred();
|
<button>reset</button>
|
||||||
|
<p>pending</p>
|
||||||
return {
|
`,
|
||||||
promise: d.promise
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
async test({ assert, target, component }) {
|
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 Promise.resolve();
|
||||||
await Promise.resolve();
|
await Promise.resolve();
|
||||||
await tick();
|
await tick();
|
||||||
flushSync();
|
flushSync();
|
||||||
assert.htmlEqual(target.innerHTML, '<p class="cool">hello</p>');
|
|
||||||
|
|
||||||
d = deferred();
|
const p = target.querySelector('p');
|
||||||
component.promise = d.promise;
|
ok(p);
|
||||||
await tick();
|
assert.htmlEqual(p.outerHTML, '<p class="cool">hello</p>');
|
||||||
assert.htmlEqual(target.innerHTML, '<p class="cool">hello</p>');
|
|
||||||
|
flushSync(() => reset.click());
|
||||||
|
assert.htmlEqual(p.outerHTML, '<p class="cool">hello</p>');
|
||||||
|
|
||||||
d.resolve('neat');
|
flushSync(() => neat.click());
|
||||||
await tick();
|
await tick();
|
||||||
assert.htmlEqual(target.innerHTML, '<p class="neat">hello</p>');
|
assert.htmlEqual(p.outerHTML, '<p class="neat">hello</p>');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in new issue