diff --git a/test/runtime/samples/await-then-catch-if/_config.js b/test/runtime/samples/await-then-catch-if/_config.js new file mode 100644 index 0000000000..1fe94768c3 --- /dev/null +++ b/test/runtime/samples/await-then-catch-if/_config.js @@ -0,0 +1,43 @@ +let fulfil; + +let thePromise = new Promise(f => { + fulfil = f; +}); + +export default { + data: { + show: true, + thePromise + }, + + html: ` +

loading...

+ `, + + test(assert, component, target) { + fulfil(42); + + return thePromise + .then(() => { + assert.htmlEqual(target.innerHTML, ` +

the value is 42

+ `); + + component.set({ + show: false + }); + + assert.htmlEqual(target.innerHTML, ` +

Else

+ `); + + component.set({ + show: true + }); + + assert.htmlEqual(target.innerHTML, ` +

the value is 42

+ `); + }); + } +}; diff --git a/test/runtime/samples/await-then-catch-if/main.html b/test/runtime/samples/await-then-catch-if/main.html new file mode 100644 index 0000000000..20449734d4 --- /dev/null +++ b/test/runtime/samples/await-then-catch-if/main.html @@ -0,0 +1,11 @@ +{{#if show}} +{{#await thePromise}} +

loading...

+{{then theValue}} +

the value is {{theValue}}

+{{catch theError}} +

oh no! {{theError.message}}

+{{/await}} +{{else}} +

Else

+{{/if}}