diff --git a/test/runtime/samples/each-block-destructured-array-as-object/_config.js b/test/runtime/samples/each-block-destructured-array-as-object/_config.js new file mode 100644 index 0000000000..ff341ce033 --- /dev/null +++ b/test/runtime/samples/each-block-destructured-array-as-object/_config.js @@ -0,0 +1,22 @@ +export default { + props: { + array: [ + [1, 2, 3, 4, 5], + [6, 7, 8], + [9, 10, 11, 12] + ] + }, + + html: ` +
First: 1, Third: 3, Length: 5
+First: 6, Third: 8, Length: 3
+First: 9, Third: 11, Length: 4
+ `, + + test({ assert, component, target }) { + component.array = [[12, 13]]; + assert.htmlEqual( target.innerHTML, ` +First: 12, Third: undefined, Length: 2
+ `); + } +}; diff --git a/test/runtime/samples/each-block-destructured-array-as-object/main.svelte b/test/runtime/samples/each-block-destructured-array-as-object/main.svelte new file mode 100644 index 0000000000..cff735555b --- /dev/null +++ b/test/runtime/samples/each-block-destructured-array-as-object/main.svelte @@ -0,0 +1,7 @@ + + +{#each array as { 0: first, '2': third, "length": length }} +First: {first}, Third: {third}, Length: {length}
+{/each} diff --git a/test/runtime/samples/each-block-destructured-object-literal-props/_config.js b/test/runtime/samples/each-block-destructured-object-literal-props/_config.js new file mode 100644 index 0000000000..0b29c28cd9 --- /dev/null +++ b/test/runtime/samples/each-block-destructured-object-literal-props/_config.js @@ -0,0 +1,22 @@ +export default { + props: { + objectsArray: [ + { 'foo-bar': 'FooBar', 0: 'zero', prop: 'prop' }, + { 'foo-bar': 'foobar', 0: 'null', prop: 'a prop' }, + { 'foo-bar': 'FOO BAR', 0: 'nada', prop: 'the prop' } + ] + }, + + html: ` +FooBar: prop zero
+foobar: a prop null
+FOO BAR: the prop nada
+ `, + + test({ assert, component, target }) { + component.objectsArray = [{ 'foo-bar': 'Fool Ball', 0: 'nil', prop: 'one prop' }]; + assert.htmlEqual( target.innerHTML, ` +Fool Ball: one prop nil
+ `); + } +}; diff --git a/test/runtime/samples/each-block-destructured-object-literal-props/main.svelte b/test/runtime/samples/each-block-destructured-object-literal-props/main.svelte new file mode 100644 index 0000000000..08826e80e9 --- /dev/null +++ b/test/runtime/samples/each-block-destructured-object-literal-props/main.svelte @@ -0,0 +1,7 @@ + + +{#each objectsArray as { 0: prop0, "foo-bar": propFooBar, prop: varProp } } +{propFooBar}: {varProp} {prop0}
+{/each} diff --git a/test/runtime/samples/each-block-destructured-object-literal-rest/_config.js b/test/runtime/samples/each-block-destructured-object-literal-rest/_config.js new file mode 100644 index 0000000000..b2f29e28f5 --- /dev/null +++ b/test/runtime/samples/each-block-destructured-object-literal-rest/_config.js @@ -0,0 +1,22 @@ +export default { + props: { + objectsArray: [ + { quote: 'q1', 'wrong-quote': 'wq1', 16: '16', class: 'class' }, + { quote: 'q2', 'wrong-quote': 'wq2', 16: 'sixteen', class: 'glass' }, + { quote: 'q3', 'wrong-quote': 'wq3', 16: 'seize', class: 'mass' } + ] + }, + + html: ` +Quote: q1, Wrong Quote: wq1, 16: 16
+Quote: q2, Wrong Quote: wq2, 16: sixteen
+Quote: q3, Wrong Quote: wq3, 16: seize
+ `, + + test({ assert, component, target }) { + component.objectsArray = [{ quote: 'new-quote', 'wrong-quote': 'wq4', 16: 'ten+six', role: 'role' }]; + assert.htmlEqual(target.innerHTML, ` +Quote: new-quote, Wrong Quote: wq4, 16: ten+six
+ `); + } +}; diff --git a/test/runtime/samples/each-block-destructured-object-literal-rest/main.svelte b/test/runtime/samples/each-block-destructured-object-literal-rest/main.svelte new file mode 100644 index 0000000000..943b3b7940 --- /dev/null +++ b/test/runtime/samples/each-block-destructured-object-literal-rest/main.svelte @@ -0,0 +1,7 @@ + + +{#each objectsArray as { "quote": quotedProp, "wrong-quote": wrongQuote, 16: sixteen, ...props } } +Quote: {quotedProp}, Wrong Quote: {wrongQuote}, 16: {sixteen}
+{/each}