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

66 lines
1012 B

export default {
get props() {
return {
thePromise: new Promise((_) => {})
};
},
html: `
loading...
`,
async test({ assert, component, target }) {
await (component.thePromise = Promise.resolve([10, 11, 12, 13, 14, 15]));
assert.htmlEqual(
target.innerHTML,
`
<p>[1] 11</p>
<p>[3] 13</p>
<p>[4] 14</p>
`
);
await (component.thePromise = Promise.resolve({ 1: 21, 3: 23, 4: 24 }));
assert.htmlEqual(
target.innerHTML,
`
<p>[1] 21</p>
<p>[3] 23</p>
<p>[4] 24</p>
`
);
try {
await (component.thePromise = Promise.reject([30, 31, 32, 33, 34, 35]));
} catch (e) {
// do nothing
}
assert.htmlEqual(
target.innerHTML,
`
<p>[0] 30</p>
<p>[2] 32</p>
<p>[5] 35</p>
`
);
try {
await (component.thePromise = Promise.reject({ 0: 40, 2: 42, 5: 45 }));
} catch (e) {
// do nothing
}
assert.htmlEqual(
target.innerHTML,
`
<p>[0] 40</p>
<p>[2] 42</p>
<p>[5] 45</p>
`
);
}
};