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-then-catch/_config.js

47 lines
713 B

7 years ago
let fulfil;
let thePromise = new Promise(f => {
fulfil = f;
});
export default {
props: {
7 years ago
thePromise
},
html: `
<p>loading...</p>
`,
test({ assert, component, target }) {
7 years ago
fulfil(42);
return thePromise
.then(() => {
assert.htmlEqual(target.innerHTML, `
<p>the value is 42</p>
`);
7 years ago
let reject;
7 years ago
thePromise = new Promise((f, r) => {
reject = r;
});
7 years ago
component.thePromise = thePromise;
7 years ago
assert.htmlEqual(target.innerHTML, `
<p>loading...</p>
`);
7 years ago
reject(new Error('something broke'));
return thePromise.catch(() => {});
})
.then(() => {
assert.htmlEqual(target.innerHTML, `
<p>oh no! something broke</p>
`);
});
7 years ago
}
};