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-with-update-catch-scope/_config.js

52 lines
774 B

export default {
props: {
thePromise: new Promise((_) => {})
},
html: `
<div>error: undefined</div>
`,
async test({ assert, component, target }) {
await (component.thePromise = Promise.resolve('abc'));
assert.htmlEqual(
target.innerHTML,
`
<div>
error: undefined
After Resolve: undefined
</div>
`
);
component.error = 'external error occurred';
assert.htmlEqual(
target.innerHTML,
`
<div>
error: ${component.error}
After Resolve: ${component.error}
</div>
`
);
try {
await (component.thePromise = Promise.reject('failure'));
} catch (error) {
// ignore
}
assert.htmlEqual(
target.innerHTML,
`
<div>
error: ${component.error}
Rejected: failure
</div>
`
);
}
};