mirror of https://github.com/sveltejs/svelte
parent
27b46a98ce
commit
68f59c0cce
@ -1,33 +1,51 @@
|
|||||||
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({
|
||||||
html: `<p>pending</p>`,
|
html: `
|
||||||
|
<button>reset</button>
|
||||||
get props() {
|
<button>hello</button>
|
||||||
d = deferred();
|
<button>again</button>
|
||||||
|
<p>pending</p>
|
||||||
|
`,
|
||||||
|
|
||||||
return {
|
async test({ assert, target }) {
|
||||||
promise: d.promise
|
const [reset, hello, again] = target.querySelectorAll('button');
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
async test({ assert, target, component }) {
|
hello.click();
|
||||||
d.resolve('hello');
|
|
||||||
await tick();
|
await tick();
|
||||||
assert.htmlEqual(target.innerHTML, '<h1>hello</h1>');
|
assert.htmlEqual(
|
||||||
|
target.innerHTML,
|
||||||
|
`
|
||||||
|
<button>reset</button>
|
||||||
|
<button>hello</button>
|
||||||
|
<button>again</button>
|
||||||
|
<h1>hello</h1>
|
||||||
|
`
|
||||||
|
);
|
||||||
|
|
||||||
d = deferred();
|
reset.click();
|
||||||
component.promise = d.promise;
|
|
||||||
await tick();
|
await tick();
|
||||||
assert.htmlEqual(target.innerHTML, '<h1>hello</h1>');
|
assert.htmlEqual(
|
||||||
|
target.innerHTML,
|
||||||
|
`
|
||||||
|
<button>reset</button>
|
||||||
|
<button>hello</button>
|
||||||
|
<button>again</button>
|
||||||
|
<h1>hello</h1>
|
||||||
|
`
|
||||||
|
);
|
||||||
|
|
||||||
d.resolve('hello again');
|
again.click();
|
||||||
await tick();
|
await tick();
|
||||||
assert.htmlEqual(target.innerHTML, '<h1>hello again</h1>');
|
assert.htmlEqual(
|
||||||
|
target.innerHTML,
|
||||||
|
`
|
||||||
|
<button>reset</button>
|
||||||
|
<button>hello</button>
|
||||||
|
<button>again</button>
|
||||||
|
<h1>hello again</h1>
|
||||||
|
`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1,32 +1,51 @@
|
|||||||
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({
|
||||||
html: `<p>pending</p>`,
|
html: `
|
||||||
|
<button>reset</button>
|
||||||
get props() {
|
<button>hello</button>
|
||||||
d = deferred();
|
<button>wheee</button>
|
||||||
|
<p>pending</p>
|
||||||
|
`,
|
||||||
|
|
||||||
return {
|
async test({ assert, target }) {
|
||||||
promise: d.promise
|
const [reset, hello, wheee] = target.querySelectorAll('button');
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
async test({ assert, target, component }) {
|
hello.click();
|
||||||
d.resolve('hello');
|
|
||||||
await tick();
|
await tick();
|
||||||
assert.htmlEqual(target.innerHTML, '<h1>hello</h1>');
|
assert.htmlEqual(
|
||||||
|
target.innerHTML,
|
||||||
|
`
|
||||||
|
<button>reset</button>
|
||||||
|
<button>hello</button>
|
||||||
|
<button>wheee</button>
|
||||||
|
<h1>hello</h1>
|
||||||
|
`
|
||||||
|
);
|
||||||
|
|
||||||
component.promise = (d = deferred()).promise;
|
reset.click();
|
||||||
await tick();
|
await tick();
|
||||||
assert.htmlEqual(target.innerHTML, '<h1>hello</h1>');
|
assert.htmlEqual(
|
||||||
|
target.innerHTML,
|
||||||
|
`
|
||||||
|
<button>reset</button>
|
||||||
|
<button>hello</button>
|
||||||
|
<button>wheee</button>
|
||||||
|
<h1>hello</h1>
|
||||||
|
`
|
||||||
|
);
|
||||||
|
|
||||||
d.resolve('wheee');
|
wheee.click();
|
||||||
await tick();
|
await tick();
|
||||||
assert.htmlEqual(target.innerHTML, '<h1>wheee</h1>');
|
assert.htmlEqual(
|
||||||
|
target.innerHTML,
|
||||||
|
`
|
||||||
|
<button>reset</button>
|
||||||
|
<button>hello</button>
|
||||||
|
<button>wheee</button>
|
||||||
|
<h1>wheee</h1>
|
||||||
|
`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1,32 +1,51 @@
|
|||||||
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({
|
||||||
html: `<p>pending</p>`,
|
html: `
|
||||||
|
<button>reset</button>
|
||||||
get props() {
|
<button>h1</button>
|
||||||
d = deferred();
|
<button>h2</button>
|
||||||
|
<p>pending</p>
|
||||||
|
`,
|
||||||
|
|
||||||
return {
|
async test({ assert, target }) {
|
||||||
promise: d.promise
|
const [reset, h1, h2] = target.querySelectorAll('button');
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
async test({ assert, target, component }) {
|
h1.click();
|
||||||
d.resolve('h1');
|
|
||||||
await tick();
|
await tick();
|
||||||
assert.htmlEqual(target.innerHTML, '<h1>hello</h1>');
|
assert.htmlEqual(
|
||||||
|
target.innerHTML,
|
||||||
|
`
|
||||||
|
<button>reset</button>
|
||||||
|
<button>h1</button>
|
||||||
|
<button>h2</button>
|
||||||
|
<h1>hello</h1>
|
||||||
|
`
|
||||||
|
);
|
||||||
|
|
||||||
component.promise = (d = deferred()).promise;
|
reset.click();
|
||||||
await tick();
|
await tick();
|
||||||
assert.htmlEqual(target.innerHTML, '<h1>hello</h1>');
|
assert.htmlEqual(
|
||||||
|
target.innerHTML,
|
||||||
|
`
|
||||||
|
<button>reset</button>
|
||||||
|
<button>h1</button>
|
||||||
|
<button>h2</button>
|
||||||
|
<h1>hello</h1>
|
||||||
|
`
|
||||||
|
);
|
||||||
|
|
||||||
d.resolve('h2');
|
h2.click();
|
||||||
await tick();
|
await tick();
|
||||||
assert.htmlEqual(target.innerHTML, '<h2>hello</h2>');
|
assert.htmlEqual(
|
||||||
|
target.innerHTML,
|
||||||
|
`
|
||||||
|
<button>reset</button>
|
||||||
|
<button>h1</button>
|
||||||
|
<button>h2</button>
|
||||||
|
<h2>hello</h2>
|
||||||
|
`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in new issue