diff --git a/test/runtime/samples/await-then-destruct-number-props/_config.js b/test/runtime/samples/await-then-destruct-number-props/_config.js new file mode 100644 index 0000000000..6ef5e978d1 --- /dev/null +++ b/test/runtime/samples/await-then-destruct-number-props/_config.js @@ -0,0 +1,63 @@ +export default { + props: { + thePromise: new Promise(_ => {}) + }, + + html: ` + loading... + `, + + async test({ assert, component, target }) { + await (component.thePromise = Promise.resolve([10, 11, 12, 13, 14, 15])); + + assert.htmlEqual( + target.innerHTML, + ` +

[1] 11

+

[3] 13

+

[4] 14

+ ` + ); + + await (component.thePromise = Promise.resolve({ 1: 21, 3: 23, 4: 24 })); + + assert.htmlEqual( + target.innerHTML, + ` +

[1] 21

+

[3] 23

+

[4] 24

+ ` + ); + + try { + await (component.thePromise = Promise.reject([30, 31, 32, 33, 34, 35])); + } catch (e) { + // do nothing + } + + assert.htmlEqual( + target.innerHTML, + ` +

[0] 30

+

[2] 32

+

[5] 35

+ ` + ); + + try { + await (component.thePromise = Promise.reject({ 0: 40, 2: 42, 5: 45 })); + } catch (e) { + // do nothing + } + + assert.htmlEqual( + target.innerHTML, + ` +

[0] 40

+

[2] 42

+

[5] 45

+ ` + ); + } +}; diff --git a/test/runtime/samples/await-then-destruct-number-props/main.svelte b/test/runtime/samples/await-then-destruct-number-props/main.svelte new file mode 100644 index 0000000000..aaeee9b353 --- /dev/null +++ b/test/runtime/samples/await-then-destruct-number-props/main.svelte @@ -0,0 +1,15 @@ + + +{#await thePromise} + loading... +{:then { 1: a, 3: b, 4: c }} +

[1] {a}

+

[3] {b}

+

[4] {c}

+{:catch { 0: d, 2: e, 5: f }} +

[0] {d}

+

[2] {e}

+

[5] {f}

+{/await} diff --git a/test/runtime/samples/await-then-destruct-string-props/_config.js b/test/runtime/samples/await-then-destruct-string-props/_config.js new file mode 100644 index 0000000000..6517f6bf20 --- /dev/null +++ b/test/runtime/samples/await-then-destruct-string-props/_config.js @@ -0,0 +1,17 @@ +export default { + async test({ assert, target }) { + await Promise.resolve(); + + assert.htmlEqual( + target.innerHTML, + ` +

prop-1: 1

+

prop4: 4

+

rest: {"prop2":2,"prop-3":3}

+

prop-7: 7

+

prop6: 6

+

rest: {"prop-5":5,"prop8":8}

+ ` + ); + } +}; diff --git a/test/runtime/samples/await-then-destruct-string-props/main.svelte b/test/runtime/samples/await-then-destruct-string-props/main.svelte new file mode 100644 index 0000000000..608b1161f5 --- /dev/null +++ b/test/runtime/samples/await-then-destruct-string-props/main.svelte @@ -0,0 +1,19 @@ + + +{#await object then { 'prop-1': prop1, 'prop4': fourthProp, ...rest }} +

prop-1: {prop1}

+

prop4: {fourthProp}

+

rest: {JSON.stringify(rest)}

+{/await} + +{#await objectReject then value} + resolved +{:catch { 'prop-7': prop7, 'prop6': sixthProp, ...rest }} +

prop-7: {prop7}

+

prop6: {sixthProp}

+

rest: {JSON.stringify(rest)}

+{/await} +