From aeabf1cca51432c637eeba1115fbfb6376d378df Mon Sep 17 00:00:00 2001 From: Tim Hall Date: Mon, 4 Dec 2017 16:00:55 -0500 Subject: [PATCH] Failing test for #974 --- .../await-then-catch-anchor/_config.js | 49 +++++++++++++++++++ .../samples/await-then-catch-anchor/main.html | 9 ++++ 2 files changed, 58 insertions(+) create mode 100644 test/runtime/samples/await-then-catch-anchor/_config.js create mode 100644 test/runtime/samples/await-then-catch-anchor/main.html diff --git a/test/runtime/samples/await-then-catch-anchor/_config.js b/test/runtime/samples/await-then-catch-anchor/_config.js new file mode 100644 index 0000000000..697c119ccd --- /dev/null +++ b/test/runtime/samples/await-then-catch-anchor/_config.js @@ -0,0 +1,49 @@ +let fulfil; + +let thePromise = new Promise(f => { + fulfil = f; +}); + +export default { + data: { + thePromise + }, + + html: ` +

loading...

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

the value is 42

+ `); + + let reject; + + thePromise = new Promise((f, r) => { + reject = r; + }); + + component.set({ + thePromise + }); + + assert.htmlEqual(target.innerHTML, ` +

loading...

+ `); + + reject(new Error('something broke')); + + return thePromise.catch(() => {}); + }) + .then(() => { + assert.htmlEqual(target.innerHTML, ` +

oh no! something broke

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

loading...

+{{then theValue}} +

the value is {{theValue}}

+{{catch theError}} +

oh no! {{theError.message}}

+{{/await}} +