mirror of https://github.com/sveltejs/svelte
Merge branch 'await-then-catch-order' of https://github.com/RedHatter/svelte into RedHatter-await-then-catch-order
commit
327a58128a
@ -0,0 +1,27 @@
|
||||
let fulfil;
|
||||
|
||||
let thePromise = new Promise(f => {
|
||||
fulfil = f;
|
||||
});
|
||||
|
||||
export default {
|
||||
data: {
|
||||
thePromise
|
||||
},
|
||||
|
||||
html: `
|
||||
<p>loading...</p><p>true!</p>
|
||||
`,
|
||||
|
||||
test(assert, component, target) {
|
||||
fulfil(42);
|
||||
|
||||
return thePromise
|
||||
.then(() => {
|
||||
assert.htmlEqual(target.innerHTML, `
|
||||
<p>the value is 42</p><p>true!</p>
|
||||
`);
|
||||
});
|
||||
|
||||
}
|
||||
};
|
@ -0,0 +1,11 @@
|
||||
{#await thePromise}
|
||||
<p>loading...</p>
|
||||
{:then theValue}
|
||||
<p>the value is {theValue}</p>
|
||||
{:catch theError}
|
||||
<p>oh no! {theError.message}</p>
|
||||
{/await}
|
||||
|
||||
{#if true}
|
||||
<p>true!</p>
|
||||
{/if}
|
Loading…
Reference in new issue