import { create_deferred } from '../../../helpers.js';
let deferred;
export default {
before_test() {
deferred = create_deferred();
},
get props() {
return { thePromise: deferred.promise };
},
html: `
the promise is pending
`, expect_unhandled_rejections: true, async test({ assert, component, target }) { deferred.resolve(); await deferred.promise; assert.htmlEqual( target.innerHTML, `the promise is resolved
the promise is resolved
the promise is resolved
` ); const local = (deferred = create_deferred()); component.thePromise = local.promise; assert.htmlEqual( target.innerHTML, `the promise is pending
` ); local.reject(new Error('something broke')); try { await local.promise; } catch {} assert.htmlEqual( target.innerHTML, `oh no! something broke