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

59 lines
949 B

import { create_deferred } from '../../../helpers.js';
let deferred;
export default {
before_test() {
deferred = create_deferred();
},
get props() {
return { thePromise: deferred.promise };
},
html: `
<p>loading...</p>
<p>loading...</p>
`,
test({ assert, component, target }) {
deferred.resolve(42);
return deferred.promise
.then(() => {
assert.htmlEqual(
target.innerHTML,
`
<p>the value is 42</p>
<p>the value is 42</p>
`
);
deferred = create_deferred();
component.thePromise = deferred.promise;
assert.htmlEqual(
target.innerHTML,
`
<p>loading...</p>
<p>loading...</p>
`
);
deferred.reject(new Error('something broke'));
return deferred.promise.catch(() => {});
})
.then(() => {
assert.htmlEqual(
target.innerHTML,
`
<p>oh no! something broke</p>
<p>oh no! something broke</p>
`
);
});
}
};