You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
svelte/test/runtime/samples/binding-select/_config.js

46 lines
959 B

export default {
html: `
<p>selected: one</p>
<select>
7 years ago
<option value='one'>one</option>
<option value='two'>two</option>
<option value='three'>three</option>
</select>
<p>selected: one</p>
`,
data: {
selected: 'one'
},
test ( assert, component, target, window ) {
const select = target.querySelector( 'select' );
const options = [ ...target.querySelectorAll( 'option' ) ];
assert.deepEqual( options, select.options );
assert.equal( component.get( 'selected' ), 'one' );
const change = new window.Event( 'change' );
options[1].selected = true;
select.dispatchEvent( change );
assert.equal( component.get( 'selected' ), 'two' );
assert.htmlEqual( target.innerHTML, `
<p>selected: two</p>
<select>
7 years ago
<option value='one'>one</option>
<option value='two'>two</option>
<option value='three'>three</option>
</select>
<p>selected: two</p>
` );
component.set({ selected: 'three' });
}
};