mirror of https://github.com/sveltejs/svelte
parent
33fb0df51a
commit
51cd9e8aba
@ -1,22 +1,22 @@
|
|||||||
export default {
|
export default {
|
||||||
data: {
|
data: {
|
||||||
options: [ { id: 'a' }, { id: 'b' }, { id: 'c' } ],
|
options: [ { id: 'a' }, { id: 'b' }, { id: 'c' } ],
|
||||||
selected: 'b'
|
selected: 'b'
|
||||||
},
|
},
|
||||||
|
|
||||||
test ( assert, component, target, window ) {
|
test ( assert, component, target, window ) {
|
||||||
const select = target.querySelector( 'select' );
|
const select = target.querySelector( 'select' );
|
||||||
assert.equal( select.value, 'b' );
|
assert.equal( select.value, 'b' );
|
||||||
|
|
||||||
const event = new window.Event( 'update' );
|
const event = new window.Event( 'change' );
|
||||||
|
|
||||||
select.value = 'c';
|
select.value = 'c';
|
||||||
select.dispatchEvent( event );
|
select.dispatchEvent( event );
|
||||||
|
|
||||||
assert.equal( select.value, 'c' );
|
assert.equal( select.value, 'c' );
|
||||||
assert.equal( component.get( 'lastChangedTo' ), 'c' );
|
assert.equal( component.get( 'lastChangedTo' ), 'c' );
|
||||||
assert.equal( component.get( 'selected' ), 'c' );
|
assert.equal( component.get( 'selected' ), 'c' );
|
||||||
|
|
||||||
component.destroy();
|
component.destroy();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
<select bind:value="selected" on:change="updateLastChangedTo(selected)">
|
<select bind:value="selected" on:change="updateLastChangedTo(selected)">
|
||||||
{{#each options as option}}
|
{{#each options as option}}
|
||||||
<option value="{{option.id}}">{{option.id}}</option>
|
<option value="{{option.id}}">{{option.id}}</option>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
methods: {
|
methods: {
|
||||||
updateLastChangedTo(result) {
|
updateLastChangedTo(result) {
|
||||||
this.set({ lastChangedTo: result })
|
this.set({ lastChangedTo: result });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in new issue