add await blowback reactive test case

pull/3883/head
AlbertLucianto 5 years ago committed by Conduitry
parent f3650a6ff6
commit 0052a9145b

@ -0,0 +1,15 @@
<script>
export let options = [];
export let index = 0;
export let value;
$: {
value = options[index];
}
</script>
<select bind:value={index}>
{#each options as option, i}
<option value={i}>{option}</option>
{/each}
</select>

@ -0,0 +1,19 @@
export default {
async test({ assert, component, target }) {
assert.htmlEqual(target.innerHTML, 'Loading...');
await component.promise;
const span = target.querySelector('span');
assert.equal(span.textContent, 'a');
const select = target.querySelector('select');
const options = [...target.querySelectorAll('option')];
const change = new window.Event('change');
options[1].selected = true;
await select.dispatchEvent(change);
assert.equal(span.textContent, 'b');
}
};

@ -0,0 +1,12 @@
<script>
import Widget from './Widget.svelte';
let promise = Promise.resolve(['a', 'b']);
let value;
</script>
{#await promise}
Loading...
{:then options}
<Widget {options} bind:value />
<span>{value}</span>
{/await}
Loading…
Cancel
Save