File tree Expand file tree Collapse file tree 2 files changed +10
-8
lines changed Expand file tree Collapse file tree 2 files changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -744,11 +744,7 @@ export default class Wrapper implements BaseWrapper {
744
744
// $FlowIgnore
745
745
const type = this . attributes ( ) . type
746
746
747
- if ( tagName === 'SELECT' ) {
748
- // $FlowIgnore
749
- this . element . value = value
750
- this . trigger ( 'change' )
751
- } else if ( tagName === 'OPTION' ) {
747
+ if ( tagName === 'OPTION' ) {
752
748
throwError (
753
749
`wrapper.setValue() cannot be called on an <option> ` +
754
750
`element. Use wrapper.setSelected() instead`
@@ -765,10 +761,16 @@ export default class Wrapper implements BaseWrapper {
765
761
`type="radio" /> element. Use wrapper.setChecked() ` +
766
762
`instead`
767
763
)
768
- } else if ( tagName === 'INPUT' || tagName === 'TEXTAREA' ) {
764
+ } else if (
765
+ tagName === 'INPUT' ||
766
+ tagName === 'TEXTAREA' ||
767
+ tagName === 'SELECT'
768
+ ) {
769
+ // $FlowIgnore
770
+ const event = tagName === 'SELECT' ? 'change' : 'input'
769
771
// $FlowIgnore
770
772
this . element . value = value
771
- this . trigger ( 'input' )
773
+ this . trigger ( event )
772
774
} else {
773
775
throwError ( `wrapper.setValue() cannot be called on this element` )
774
776
}
Original file line number Diff line number Diff line change 1
1
import ComponentWithInput from '~resources/components/component-with-input.vue'
2
2
import { describeWithShallowAndMount } from '~resources/utils'
3
3
4
- describeWithShallowAndMount . only ( 'setSelected' , mountingMethod => {
4
+ describeWithShallowAndMount ( 'setSelected' , mountingMethod => {
5
5
it ( 'sets element selected true' , ( ) => {
6
6
const wrapper = mountingMethod ( ComponentWithInput )
7
7
const options = wrapper . find ( 'select' ) . findAll ( 'option' )
You can’t perform that action at this time.
0 commit comments