You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
svelte/test/runtime/samples/await-catch-no-expression/_config.js

48 lines
690 B

let fulfil;
let thePromise = new Promise(f => {
fulfil = f;
});
export default {
props: {
thePromise
},
html: `
<br />
<p>the promise is pending</p>
`,
async test({ assert, component, target }) {
fulfil(42);
await thePromise;
assert.htmlEqual(target.innerHTML, '<br />');
let reject;
thePromise = new Promise((f, r) => {
reject = r;
});
component.thePromise = thePromise;
assert.htmlEqual(target.innerHTML, `
<br />
<p>the promise is pending</p>
`);
reject(new Error());
await thePromise.catch(() => {});
assert.htmlEqual(target.innerHTML, `
<p>oh no! Something broke!</p>
<br />
<p>oh no! Something broke!</p>
`);
}
};