diff --git a/test/runtime/samples/$$slot-dynamic/A.svelte b/test/runtime/samples/$$slot-dynamic/A.svelte new file mode 100644 index 0000000000..6228fd9c11 --- /dev/null +++ b/test/runtime/samples/$$slot-dynamic/A.svelte @@ -0,0 +1,27 @@ + + +$$slots: {toString($$slots)} + +{#if $$slots[slot_1]} + +{:else} + Slot aaaaa is not available +{/if} + +{#if $$slots[slot_2]} +
+ +
+{:else} + Slot abab is not available +{/if} diff --git a/test/runtime/samples/$$slot-dynamic/_config.js b/test/runtime/samples/$$slot-dynamic/_config.js new file mode 100644 index 0000000000..0473e45f03 --- /dev/null +++ b/test/runtime/samples/$$slot-dynamic/_config.js @@ -0,0 +1,15 @@ +export default { + html: ` + $$slots: {"aaaaa":true} + hello aaaaa + Slot abab is not available + + $$slots: {"abab":true} + Slot aaaaa is not available + +
hello abab
+ $$slots: {"aaaaa":true,"abab":true} + hello aaaaa +
hello abab
+ ` +}; diff --git a/test/runtime/samples/$$slot-dynamic/main.svelte b/test/runtime/samples/$$slot-dynamic/main.svelte new file mode 100644 index 0000000000..6b861e9fab --- /dev/null +++ b/test/runtime/samples/$$slot-dynamic/main.svelte @@ -0,0 +1,16 @@ + + + + hello aaaaa + + + + hello abab + + + + hello aaaaa + hello abab + diff --git a/test/runtime/samples/await-then-catch-in-dynamic-slot/Foo.svelte b/test/runtime/samples/await-then-catch-in-dynamic-slot/Foo.svelte new file mode 100644 index 0000000000..ab283a7015 --- /dev/null +++ b/test/runtime/samples/await-then-catch-in-dynamic-slot/Foo.svelte @@ -0,0 +1,8 @@ + +{#each states as state} + {#if $$slots[state]} + + {/if} +{/each} diff --git a/test/runtime/samples/await-then-catch-in-dynamic-slot/_config.js b/test/runtime/samples/await-then-catch-in-dynamic-slot/_config.js new file mode 100644 index 0000000000..77941f91be --- /dev/null +++ b/test/runtime/samples/await-then-catch-in-dynamic-slot/_config.js @@ -0,0 +1,53 @@ +let fulfil; + +let thePromise = new Promise(f => { + fulfil = f; +}); + +export default { + props: { + thePromise + }, + + html: ` +

loading pending...

+

loading then...

+

loading catch...

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

loading pending...

+

the value is 42

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

loading pending...

+

loading then...

+

loading catch...

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

loading pending...

+

oh no! something broke

+ `); + }); + } +}; diff --git a/test/runtime/samples/await-then-catch-in-dynamic-slot/main.svelte b/test/runtime/samples/await-then-catch-in-dynamic-slot/main.svelte new file mode 100644 index 0000000000..938f239b6b --- /dev/null +++ b/test/runtime/samples/await-then-catch-in-dynamic-slot/main.svelte @@ -0,0 +1,27 @@ + + + +

loading pending...

+ + {#await thePromise} +

loading then...

+ {:then theValue} +

the value is {theValue}

+ {/await} +
+ + {#await thePromise} +

loading catch...

+ {:catch theError} +

oh no! {theError.message}

+ {/await} +
+ +
diff --git a/test/runtime/samples/component-dynamic-slot-attribute-order/Component.svelte b/test/runtime/samples/component-dynamic-slot-attribute-order/Component.svelte new file mode 100644 index 0000000000..0f481a4042 --- /dev/null +++ b/test/runtime/samples/component-dynamic-slot-attribute-order/Component.svelte @@ -0,0 +1 @@ + diff --git a/test/runtime/samples/component-dynamic-slot-attribute-order/_config.js b/test/runtime/samples/component-dynamic-slot-attribute-order/_config.js new file mode 100644 index 0000000000..3eae9fc2df --- /dev/null +++ b/test/runtime/samples/component-dynamic-slot-attribute-order/_config.js @@ -0,0 +1,15 @@ +export default { + html: ` + + + + `, + async test({ assert, target, window }) { + const [btn, btn1, btn2] = target.querySelectorAll('button'); + + await btn.dispatchEvent(new window.MouseEvent('click')); + + assert.equal(btn1.disabled, true); + assert.equal(btn2.disabled, true); + } +}; diff --git a/test/runtime/samples/component-dynamic-slot-attribute-order/main.svelte b/test/runtime/samples/component-dynamic-slot-attribute-order/main.svelte new file mode 100644 index 0000000000..c5857252e4 --- /dev/null +++ b/test/runtime/samples/component-dynamic-slot-attribute-order/main.svelte @@ -0,0 +1,16 @@ + + + + + + + + + + + diff --git a/test/runtime/samples/component-slot-dynamic-slot/Component.svelte b/test/runtime/samples/component-slot-dynamic-slot/Component.svelte new file mode 100644 index 0000000000..1ff1291a21 --- /dev/null +++ b/test/runtime/samples/component-slot-dynamic-slot/Component.svelte @@ -0,0 +1,6 @@ + +
+ +
diff --git a/test/runtime/samples/component-slot-dynamic-slot/Forward.svelte b/test/runtime/samples/component-slot-dynamic-slot/Forward.svelte new file mode 100644 index 0000000000..2a8c083636 --- /dev/null +++ b/test/runtime/samples/component-slot-dynamic-slot/Forward.svelte @@ -0,0 +1,10 @@ + + + + + diff --git a/test/runtime/samples/component-slot-dynamic-slot/_config.js b/test/runtime/samples/component-slot-dynamic-slot/_config.js new file mode 100644 index 0000000000..29d7d0cfd5 --- /dev/null +++ b/test/runtime/samples/component-slot-dynamic-slot/_config.js @@ -0,0 +1,3 @@ +export default { + html: '
lol
' +}; diff --git a/test/runtime/samples/component-slot-dynamic-slot/main.svelte b/test/runtime/samples/component-slot-dynamic-slot/main.svelte new file mode 100644 index 0000000000..56730da7e6 --- /dev/null +++ b/test/runtime/samples/component-slot-dynamic-slot/main.svelte @@ -0,0 +1,12 @@ + + + + + lol + + diff --git a/test/runtime/samples/component-slot-let-in-dynamic-slot/Inner.svelte b/test/runtime/samples/component-slot-let-in-dynamic-slot/Inner.svelte new file mode 100644 index 0000000000..d0ea817d54 --- /dev/null +++ b/test/runtime/samples/component-slot-let-in-dynamic-slot/Inner.svelte @@ -0,0 +1 @@ + diff --git a/test/runtime/samples/component-slot-let-in-dynamic-slot/Outer.svelte b/test/runtime/samples/component-slot-let-in-dynamic-slot/Outer.svelte new file mode 100644 index 0000000000..56d6eaf345 --- /dev/null +++ b/test/runtime/samples/component-slot-let-in-dynamic-slot/Outer.svelte @@ -0,0 +1,5 @@ + + + diff --git a/test/runtime/samples/component-slot-let-in-dynamic-slot/_config.js b/test/runtime/samples/component-slot-let-in-dynamic-slot/_config.js new file mode 100644 index 0000000000..96c43497db --- /dev/null +++ b/test/runtime/samples/component-slot-let-in-dynamic-slot/_config.js @@ -0,0 +1,25 @@ +let logs; +function log(value) { + logs.push(value); +} + +export default { + props: { + prop: 'a', + log + }, + html: '', + before_test() { + logs = []; + }, + async test({ assert, component, target, window }) { + const button = target.querySelector('button'); + await button.dispatchEvent(new window.MouseEvent('click')); + + assert.deepEqual(logs, ['a']); + + component.prop = 'b'; + await button.dispatchEvent(new window.MouseEvent('click')); + assert.deepEqual(logs, ['a', 'b']); + } +}; diff --git a/test/runtime/samples/component-slot-let-in-dynamic-slot/main.svelte b/test/runtime/samples/component-slot-let-in-dynamic-slot/main.svelte new file mode 100644 index 0000000000..96a4f8ad4d --- /dev/null +++ b/test/runtime/samples/component-slot-let-in-dynamic-slot/main.svelte @@ -0,0 +1,11 @@ + + + +