mirror of https://github.com/sveltejs/svelte
61 lines
851 B
61 lines
851 B
export default {
|
|
props: {
|
|
thePromise: new Promise((_) => {}),
|
|
count: 0
|
|
},
|
|
|
|
html: `
|
|
<div><p>loading...</p></div>
|
|
`,
|
|
|
|
async test({ assert, component, target }) {
|
|
await (component.thePromise = Promise.resolve(component.Component));
|
|
|
|
assert.htmlEqual(
|
|
target.innerHTML,
|
|
`
|
|
<div>Resolved:
|
|
<div>count: 0</div>
|
|
</div>
|
|
`
|
|
);
|
|
|
|
component.count = 5;
|
|
|
|
assert.htmlEqual(
|
|
target.innerHTML,
|
|
`
|
|
<div>Resolved:
|
|
<div>count: 5</div>
|
|
</div>
|
|
`
|
|
);
|
|
|
|
try {
|
|
await (component.thePromise = Promise.reject(component.Component));
|
|
} catch (error) {
|
|
// ignore
|
|
}
|
|
|
|
assert.htmlEqual(
|
|
target.innerHTML,
|
|
`
|
|
<div>Rejected:
|
|
<div>count: 5</div>
|
|
</div>
|
|
`
|
|
);
|
|
|
|
component.count = 10;
|
|
|
|
assert.htmlEqual(
|
|
target.innerHTML,
|
|
`
|
|
<div>Rejected:
|
|
<div>count: 10</div>
|
|
</div>
|
|
`
|
|
);
|
|
}
|
|
};
|