@@ -269,6 +269,44 @@ describe("single-select option", () => {
269
269
} ) ;
270
270
} ) ;
271
271
272
+ describe ( "multi-select options" , ( ) => {
273
+ it ( "should select an option when clicking on it" , async ( ) => {
274
+ const wrapper = mount ( VueSelect , { props : { modelValue : [ ] , isMulti : true , options } } ) ;
275
+
276
+ await openMenu ( wrapper ) ;
277
+ await wrapper . get ( "div[role='option']" ) . trigger ( "click" ) ;
278
+
279
+ expect ( wrapper . props ( "modelValue" ) ) . toStrictEqual ( [ options [ 0 ] . value ] ) ;
280
+ expect ( wrapper . get ( ".multi-value" ) . element . textContent ) . toBe ( options [ 0 ] . label ) ;
281
+ } ) ;
282
+
283
+ it ( "should display non-selected remaining options on the list" , async ( ) => {
284
+ const wrapper = mount ( VueSelect , { props : { modelValue : [ ] , isMulti : true , options } } ) ;
285
+
286
+ await openMenu ( wrapper ) ;
287
+ await wrapper . get ( "div[role='option']" ) . trigger ( "click" ) ;
288
+ await openMenu ( wrapper ) ;
289
+
290
+ expect ( wrapper . findAll ( ".menu-option" ) . length ) . toBe ( options . length - 1 ) ;
291
+ } ) ;
292
+
293
+ it ( "should remove a selected option and be able to select it again" , async ( ) => {
294
+ const wrapper = mount ( VueSelect , { props : { modelValue : [ ] , isMulti : true , options } } ) ;
295
+
296
+ await openMenu ( wrapper ) ;
297
+ await wrapper . get ( "div[role='option']" ) . trigger ( "click" ) ;
298
+ await openMenu ( wrapper ) ;
299
+
300
+ expect ( wrapper . findAll ( ".menu-option" ) . length ) . toBe ( options . length - 1 ) ;
301
+
302
+ await wrapper . get ( ".multi-value" ) . trigger ( "click" ) ;
303
+ await openMenu ( wrapper ) ;
304
+
305
+ expect ( wrapper . findAll ( ".menu-option" ) . length ) . toBe ( options . length ) ;
306
+ expect ( wrapper . findAll ( ".multi-value" ) . length ) . toBe ( 0 ) ;
307
+ } ) ;
308
+ } ) ;
309
+
272
310
describe ( "clear button" , ( ) => {
273
311
it ( "should display the clear button when an option is selected" , async ( ) => {
274
312
const wrapper = mount ( VueSelect , { props : { modelValue : null , options, isClearable : true } } ) ;
0 commit comments