mirror of https://github.com/sveltejs/svelte
allow {:then}/{:catch} to have no bound identifier (#1507)
parent
557e7b7ccb
commit
b4d7653b42
@ -0,0 +1,41 @@
|
|||||||
|
let fulfil;
|
||||||
|
|
||||||
|
let thePromise = new Promise(f => {
|
||||||
|
fulfil = f;
|
||||||
|
});
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data: {
|
||||||
|
thePromise
|
||||||
|
},
|
||||||
|
|
||||||
|
html: `waiting`,
|
||||||
|
|
||||||
|
test(assert, component, target) {
|
||||||
|
fulfil(9000);
|
||||||
|
|
||||||
|
return thePromise
|
||||||
|
.then(() => {
|
||||||
|
assert.htmlEqual(target.innerHTML, `resolved`);
|
||||||
|
|
||||||
|
let reject;
|
||||||
|
|
||||||
|
thePromise = new Promise((f, r) => {
|
||||||
|
reject = r;
|
||||||
|
});
|
||||||
|
|
||||||
|
component.set({
|
||||||
|
thePromise
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.htmlEqual(target.innerHTML, `waiting`);
|
||||||
|
|
||||||
|
reject(new Error('something broke'));
|
||||||
|
|
||||||
|
return thePromise.catch(() => {});
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
assert.htmlEqual(target.innerHTML, `rejected`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,7 @@
|
|||||||
|
{#await thePromise}
|
||||||
|
waiting
|
||||||
|
{:then}
|
||||||
|
resolved
|
||||||
|
{:catch}
|
||||||
|
rejected
|
||||||
|
{/await}
|
Loading…
Reference in new issue