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

30 lines
740 B

export default {
async test({ assert, component, target }) {
let resolve, reject;
let promise = new Promise(ok => resolve = ok);
component.promise = promise;
assert.htmlEqual(target.innerHTML, 'Loading...');
resolve(42);
await promise;
assert.htmlEqual(target.innerHTML, '42');
promise = new Promise((ok, fail) => reject = fail);
component.promise = promise;
assert.htmlEqual(target.innerHTML, 'Loading...');
reject(99);
await promise.then(null, () => {});
assert.htmlEqual(target.innerHTML, '99');
promise = new Promise(ok => resolve = ok);
component.promise = promise;
assert.htmlEqual(target.innerHTML, 'Loading...');
resolve(1);
await promise;
assert.htmlEqual(target.innerHTML, '1');
}
};