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

45 lines
788 B

let fulfil;
let thePromise = new Promise(f => {
fulfil = f;
});
export default {
props: {
thePromise
},
html: `
<p>loading...</p>
`,
test({ assert, component, target, window }) {
fulfil(42);
return thePromise
.then(async () => {
assert.htmlEqual(target.innerHTML, `
<button>click me</button>
`);
const { button } = component;
const click = new window.MouseEvent('click');
button.dispatchEvent(click);
assert.equal(component.clicked, 42);
thePromise = Promise.resolve(43);
component.thePromise = thePromise;
return thePromise;
})
.then(() => {
const { button } = component;
const click = new window.MouseEvent('click');
button.dispatchEvent(click);
assert.equal(component.clicked, 43);
});
}
};