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

44 lines
788 B

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