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-destruct-array/_config.js

62 lines
878 B

export default {
props: {
thePromise: new Promise(resolve => {})
},
html: `
loading...
`,
async test({ assert, component, target }) {
await (component.thePromise = Promise.resolve([1, 2]));
assert.htmlEqual(
target.innerHTML,
`
<p>a: 1</p>
<p>b: 2</p>
`
);
await (component.thePromise = Promise.resolve([4, 5]));
assert.htmlEqual(
target.innerHTML,
`
<p>a: 4</p>
<p>b: 5</p>
`
);
try {
await (component.thePromise = Promise.reject(['a', [6, 7]]));
} catch (e) {
// do nothing
}
assert.htmlEqual(
target.innerHTML,
`
<p>c: a</p>
<p>d: 6</p>
<p>e: 7</p>
`
);
try {
await (component.thePromise = Promise.reject(['b', [8, 9]]));
} catch (e) {
// do nothing
}
assert.htmlEqual(
target.innerHTML,
`
<p>c: b</p>
<p>d: 8</p>
<p>e: 9</p>
`
);
}
};