@@ -65,6 +65,37 @@ describeWithShallowAndMount('setValue', mountingMethod => {
65
65
expect ( wrapper . text ( ) ) . to . contain ( 'selectB' )
66
66
} )
67
67
68
+ it ( 'sets element of multiselect value' , ( ) => {
69
+ const wrapper = mountingMethod ( ComponentWithInput )
70
+ const select = wrapper . find ( 'select.multiselect' )
71
+ select . setValue ( [ 'selectA' , 'selectC' ] )
72
+
73
+ const selectedOptions = Array . from ( select . element . selectedOptions ) . map (
74
+ o => o . value
75
+ )
76
+ expect ( selectedOptions ) . to . deep . equal ( [ 'selectA' , 'selectC' ] )
77
+ } )
78
+
79
+ it ( 'overrides elements of multiselect' , ( ) => {
80
+ const wrapper = mountingMethod ( ComponentWithInput )
81
+ const select = wrapper . find ( 'select.multiselect' )
82
+ select . setValue ( [ 'selectA' , 'selectC' ] )
83
+ select . setValue ( [ 'selectB' ] )
84
+
85
+ const selectedOptions = Array . from ( select . element . selectedOptions ) . map (
86
+ o => o . value
87
+ )
88
+ expect ( selectedOptions ) . to . deep . equal ( [ 'selectB' ] )
89
+ } )
90
+
91
+ it ( 'updates dom with multiselect v-model when array' , async ( ) => {
92
+ const wrapper = mountingMethod ( ComponentWithInput )
93
+ const select = wrapper . find ( 'select.multiselect' )
94
+ await select . setValue ( [ 'selectA' , 'selectC' ] )
95
+
96
+ expect ( wrapper . text ( ) ) . to . contain ( '["selectA","selectC"]' )
97
+ } )
98
+
68
99
it ( 'throws error if element is option' , ( ) => {
69
100
const message =
70
101
'wrapper.setValue() cannot be called on an <option> element. Use wrapper.setSelected() instead'
0 commit comments