|
|
@ -1,41 +1,38 @@
|
|
|
|
import { tick } from 'svelte';
|
|
|
|
import { tick } from 'svelte';
|
|
|
|
import { deferred } from '../../../../src/internal/shared/utils.js';
|
|
|
|
|
|
|
|
import { test } from '../../test';
|
|
|
|
import { test } from '../../test';
|
|
|
|
|
|
|
|
|
|
|
|
/** @type {ReturnType<typeof deferred>} */
|
|
|
|
|
|
|
|
let d;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export default test({
|
|
|
|
export default test({
|
|
|
|
compileOptions: {
|
|
|
|
compileOptions: {
|
|
|
|
dev: true
|
|
|
|
dev: true
|
|
|
|
},
|
|
|
|
},
|
|
|
|
html: `<p>pending</p>`,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
get props() {
|
|
|
|
html: `
|
|
|
|
d = deferred();
|
|
|
|
<button>reset</button>
|
|
|
|
|
|
|
|
<button>one</button>
|
|
|
|
|
|
|
|
<button>two</button>
|
|
|
|
|
|
|
|
<button>three</button>
|
|
|
|
|
|
|
|
<p>pending</p>
|
|
|
|
|
|
|
|
`,
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
async test({ assert, target }) {
|
|
|
|
promise: d.promise
|
|
|
|
const [reset, one, two, three] = target.querySelectorAll('button');
|
|
|
|
};
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async test({ assert, target, component }) {
|
|
|
|
one.click();
|
|
|
|
d.resolve(['a', 'b', 'c']);
|
|
|
|
|
|
|
|
await tick();
|
|
|
|
await tick();
|
|
|
|
assert.htmlEqual(target.innerHTML, '<p>a</p><p>b</p><p>c</p>');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
d = deferred();
|
|
|
|
const [div] = target.querySelectorAll('div');
|
|
|
|
component.promise = d.promise;
|
|
|
|
assert.htmlEqual(div.innerHTML, '<p>a</p><p>b</p><p>c</p>');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
reset.click();
|
|
|
|
await tick();
|
|
|
|
await tick();
|
|
|
|
assert.htmlEqual(target.innerHTML, '<p>a</p><p>b</p><p>c</p>');
|
|
|
|
assert.htmlEqual(div.innerHTML, '<p>a</p><p>b</p><p>c</p>');
|
|
|
|
|
|
|
|
|
|
|
|
d.resolve(['d', 'e', 'f', 'g']);
|
|
|
|
two.click();
|
|
|
|
await tick();
|
|
|
|
await tick();
|
|
|
|
assert.htmlEqual(target.innerHTML, '<p>d</p><p>e</p><p>f</p><p>g</p>');
|
|
|
|
assert.htmlEqual(div.innerHTML, '<p>d</p><p>e</p><p>f</p><p>g</p>');
|
|
|
|
|
|
|
|
|
|
|
|
d = deferred();
|
|
|
|
reset.click();
|
|
|
|
component.promise = d.promise;
|
|
|
|
three.click();
|
|
|
|
d.resolve(['d', 'e', 'f', 'd']);
|
|
|
|
|
|
|
|
await tick();
|
|
|
|
await tick();
|
|
|
|
assert.fail('should not allow duplicate keys');
|
|
|
|
assert.fail('should not allow duplicate keys');
|
|
|
|
},
|
|
|
|
},
|
|
|
|