update some tests

pull/1864/head
Rich Harris 7 years ago
parent 4ad548c44d
commit dbb11a5500

@ -1,6 +1,7 @@
<script>
import { onMount } from 'svelte';
export let value;
export let id;
const initialValues = {

@ -14,11 +14,11 @@ export default {
</ol>
`,
test (assert, component, target, window) {
async test(assert, component, target, window) {
const input = target.querySelector('input');
input.value = 4;
input.dispatchEvent(new window.Event('input'));
await input.dispatchEvent(new window.Event('input'));
assert.htmlEqual(target.innerHTML, `
<input type='number'>

@ -16,7 +16,7 @@
<ol>
{#each ids as object (object.id)}
<Nested bind:value='idToValue[object.id]' id='{object.id}'>
<Nested bind:value={idToValue[object.id]} id={object.id}>
{object.id}: value is {idToValue[object.id]}
</Nested>
{/each}

@ -4,19 +4,19 @@ export default {
<label>lastname <input></label>
`,
test ( assert, component, target, window ) {
async test(assert, component, target, window) {
const input = new window.Event('input');
const inputs = target.querySelectorAll('input');
inputs[0].value = 'Ada';
inputs[0].dispatchEvent(input);
await inputs[0].dispatchEvent(input);
assert.deepEqual(component.values, {
firstname: 'Ada',
lastname: ''
});
inputs[1].value = 'Lovelace';
inputs[1].dispatchEvent(input);
await inputs[1].dispatchEvent(input);
assert.deepEqual(component.values, {
firstname: 'Ada',
lastname: 'Lovelace'

@ -9,5 +9,5 @@
</script>
{#each fields as field}
<Nested {field} bind:value='values[field]'/>
<Nested {field} bind:value={values[field]}/>
{/each}

@ -30,12 +30,12 @@ export default {
<pre>ONE SOURCE\nTWO SOURCE</pre>
`,
test(assert, component, target, window) {
async test(assert, component, target, window) {
const event = new window.MouseEvent('input');
const textarea = target.querySelector('textarea');
textarea.value = 'one source changed';
textarea.dispatchEvent(event);
await textarea.dispatchEvent(event);
assert.equal(component.compiled, 'ONE SOURCE CHANGED\nTWO SOURCE');
assert.htmlEqual(target.innerHTML, `
@ -65,7 +65,7 @@ export default {
assert.equal(textarea.value, 'two source');
textarea.value = 'two source changed';
textarea.dispatchEvent(event);
await textarea.dispatchEvent(event);
assert.equal(component.compiled, 'ONE SOURCE CHANGED\nTWO SOURCE CHANGED');
assert.htmlEqual(target.innerHTML, `

@ -9,12 +9,12 @@ export default {
<p>foo</p>
`,
test(assert, component, target, window) {
async test(assert, component, target, window) {
const event = new window.MouseEvent('input');
const input = target.querySelector('input');
input.value = 'blah';
input.dispatchEvent(event);
await input.dispatchEvent(event);
assert.deepEqual(component.deep, { name: 'blah' });
assert.htmlEqual(target.innerHTML, `

@ -11,12 +11,12 @@ export default {
<p>foo, bar, baz</p>
`,
test(assert, component, target, window) {
async test(assert, component, target, window) {
const event = new window.MouseEvent('input');
const inputs = target.querySelectorAll('input');
inputs[0].value = 'blah';
inputs[0].dispatchEvent(event);
await inputs[0].dispatchEvent(event);
assert.deepEqual(component.a, [{ name: 'blah' }, { name: 'bar' }, { name: 'baz' }]);
assert.htmlEqual(target.innerHTML, `

@ -11,12 +11,12 @@ export default {
<p>foo, bar, baz</p>
`,
test(assert, component, target, window) {
async test(assert, component, target, window) {
const event = new window.MouseEvent('input');
const inputs = target.querySelectorAll('input');
inputs[0].value = 'blah';
inputs[0].dispatchEvent(event);
await inputs[0].dispatchEvent(event);
assert.deepEqual(component.a, [ 'blah', 'bar', 'baz' ]);
assert.htmlEqual(target.innerHTML, `

@ -25,7 +25,7 @@ export default {
<p><span class=''>1</span></p>
`,
test ( assert, component, target, window ) {
async test(assert, component, target, window) {
const click = new window.MouseEvent('click');
const spans = target.querySelectorAll('span');

@ -6,5 +6,5 @@
</script>
<div>
<Widget on:select='{event => dispatch("select", event.selection)}'/>
<Widget on:select='{event => dispatch("select", event.detail.selection)}'/>
</div>
Loading…
Cancel
Save