@@ -103,7 +103,7 @@ describe(`MultiSelect`, () => {
103103 // this doesn't work for unknown reasons
104104 // document
105105 // .querySelector(`ul.options > li`)
106- // ?.dispatchEvent(new Event (`mouseover`, { bubbles: true }))
106+ // ?.dispatchEvent(new MouseEvent (`mouseover`, { bubbles: true }))
107107
108108 for ( const [ class_name , elem_type ] of Object . entries ( css_classes ) ) {
109109 const el = doc_query ( `.${ class_name } ` )
@@ -140,7 +140,7 @@ describe(`MultiSelect`, () => {
140140 await sleep ( )
141141 input . dispatchEvent ( new KeyboardEvent ( `keydown` , { key : `Enter` } ) )
142142 await sleep ( )
143- const selected = doc_query ( `div.multiselect > ul.selected` )
143+ const selected = doc_query ( `ul.selected` )
144144
145145 expect ( selected . textContent ?. trim ( ) ) . toBe ( `1` )
146146
@@ -186,29 +186,29 @@ describe(`MultiSelect`, () => {
186186 }
187187 } )
188188
189- test ( `selected is a single option (not length-1 array ) when maxSelect=1` , async ( ) => {
189+ test ( `value is a single option (i.e. selected[0] ) when maxSelect=1` , async ( ) => {
190190 const options = [ 1 , 2 , 3 ]
191191
192192 const instance = new MultiSelect ( {
193193 target : document . body ,
194194 props : { options, maxSelect : 1 , selected : options } ,
195195 } )
196196
197- const selected = instance . $$ . ctx [ instance . $$ . props . selected ]
197+ const value = instance . $$ . ctx [ instance . $$ . props . value ]
198198
199- // this also tests that only 1st option is preselected although all options are marked such
200- expect ( selected ) . toBe ( options [ 0 ] )
199+ // this also tests that only 1st option is pre-selected although all options are marked such, i.e. no more than maxSelect options can be pre-selected
200+ expect ( value ) . toBe ( options [ 0 ] )
201201 } )
202202
203- test ( `selected is null when maxSelect=1 and no option is preselected ` , async ( ) => {
203+ test ( `selected is null when maxSelect=1 and no option is pre-selected ` , async ( ) => {
204204 const instance = new MultiSelect ( {
205205 target : document . body ,
206206 props : { options : [ 1 , 2 , 3 ] , maxSelect : 1 } ,
207207 } )
208208
209- const selected = instance . $$ . ctx [ instance . $$ . props . selected ]
209+ const value = instance . $$ . ctx [ instance . $$ . props . value ]
210210
211- expect ( selected ) . toBe ( null )
211+ expect ( value ) . toBe ( null )
212212 } )
213213
214214 test ( `selected is array of first two options when maxSelect=2` , async ( ) => {
@@ -280,7 +280,7 @@ describe(`MultiSelect`, () => {
280280
281281 // assert aria-invalid attribute is removed on selecting a new option
282282 const option = doc_query ( `ul.options > li` )
283- option . dispatchEvent ( new Event ( `mouseup` ) )
283+ option . dispatchEvent ( new MouseEvent ( `mouseup` ) )
284284 await sleep ( )
285285
286286 expect ( input . getAttribute ( `aria-invalid` ) ) . toBe ( null )
@@ -316,7 +316,7 @@ describe(`MultiSelect`, () => {
316316 input . dispatchEvent ( new InputEvent ( `input` ) )
317317 await sleep ( )
318318
319- const dropdown = doc_query ( `div.multiselect ul.options` )
319+ const dropdown = doc_query ( `ul.options` )
320320 expect ( dropdown . textContent ?. trim ( ) ) . toBe ( `bar baz` )
321321 } )
322322
@@ -341,7 +341,7 @@ describe(`MultiSelect`, () => {
341341 select . $$ . ctx [ select . $$ . props . noMatchingOptionsMsg ]
342342 }
343343
344- const dropdown = doc_query ( `div.multiselect ul.options` )
344+ const dropdown = doc_query ( `ul.options` )
345345 expect ( dropdown . textContent ?. trim ( ) ) . toBe ( noMatchingOptionsMsg )
346346 }
347347 )
@@ -353,10 +353,10 @@ describe(`MultiSelect`, () => {
353353 } )
354354
355355 document
356- . querySelector ( `div.multiselect ul.selected button[title='Remove 1']` )
357- ?. dispatchEvent ( new Event ( `mouseup` ) )
356+ . querySelector ( `ul.selected button[title='Remove 1']` )
357+ ?. dispatchEvent ( new MouseEvent ( `mouseup` ) )
358358
359- const selected = doc_query ( `div.multiselect ul.selected` )
359+ const selected = doc_query ( `ul.selected` )
360360 await sleep ( )
361361
362362 expect ( selected . textContent ?. trim ( ) ) . toEqual ( `2 3` )
@@ -367,15 +367,15 @@ describe(`MultiSelect`, () => {
367367 target : document . body ,
368368 props : { options : [ 1 , 2 , 3 ] , selected : [ 1 , 2 , 3 ] } ,
369369 } )
370- let selected = doc_query ( `div.multiselect ul.selected` )
370+ let selected = doc_query ( `ul.selected` )
371371 expect ( selected . textContent ?. trim ( ) ) . toEqual ( `1 2 3` )
372372
373373 document
374374 . querySelector ( `button[title='Remove all']` )
375- ?. dispatchEvent ( new Event ( `mouseup` ) )
375+ ?. dispatchEvent ( new MouseEvent ( `mouseup` ) )
376376 await sleep ( )
377377
378- selected = doc_query ( `div.multiselect ul.selected` )
378+ selected = doc_query ( `ul.selected` )
379379 expect ( selected . textContent ?. trim ( ) ) . toEqual ( `` )
380380
381381 // select 2 options
@@ -385,8 +385,8 @@ describe(`MultiSelect`, () => {
385385 `remove all button should only appear if more than 1 option is selected`
386386 ) . toBeNull ( )
387387
388- const li = doc_query ( `div.multiselect ul.options li` )
389- li . dispatchEvent ( new Event ( `mouseup` ) )
388+ const li = doc_query ( `ul.options li` )
389+ li . dispatchEvent ( new MouseEvent ( `mouseup` ) )
390390 await sleep ( )
391391 }
392392
@@ -405,9 +405,7 @@ describe(`MultiSelect`, () => {
405405 props : { removeAllTitle, removeBtnTitle, options, selected : options } ,
406406 } )
407407 const remove_all_btn = doc_query ( `button.remove-all` ) as HTMLButtonElement
408- const remove_btns = document . querySelectorAll (
409- `div.multiselect > ul.selected > li > button`
410- )
408+ const remove_btns = document . querySelectorAll ( `ul.selected > li > button` )
411409
412410 expect ( remove_all_btn . title ) . toBe ( removeAllTitle )
413411 expect ( [ ...remove_btns ] . map ( ( btn ) => btn . title ) ) . toEqual (
@@ -426,7 +424,7 @@ describe(`MultiSelect`, () => {
426424 li . dispatchEvent ( new MouseEvent ( `mouseup` ) )
427425 }
428426
429- const selected = doc_query ( `div.multiselect ul.selected` )
427+ const selected = doc_query ( `ul.selected` )
430428 await sleep ( )
431429
432430 expect ( selected . textContent ?. trim ( ) ) . toEqual ( `2 3` )
@@ -444,7 +442,7 @@ describe(`MultiSelect`, () => {
444442 . querySelectorAll ( `ul.options > li` )
445443 ?. forEach ( ( li ) => li . dispatchEvent ( new MouseEvent ( `mouseup` ) ) )
446444
447- const selected = doc_query ( `div.multiselect ul.selected` )
445+ const selected = doc_query ( `ul.selected` )
448446 await sleep ( )
449447
450448 expect ( selected . textContent ?. trim ( ) ) . toEqual (
@@ -503,7 +501,7 @@ describe(`MultiSelect`, () => {
503501 input . dispatchEvent ( new InputEvent ( `input` ) )
504502 await sleep ( )
505503
506- const dropdown = doc_query ( `div.multiselect ul.options` )
504+ const dropdown = doc_query ( `ul.options` )
507505
508506 const fail_msg = `options=${ options } , selected=${ selected } , duplicates=${ duplicates } , duplicateOptionMsg=${ duplicateOptionMsg } `
509507 expect ( dropdown . textContent ?. trim ( ) , fail_msg ) . toBe (
@@ -530,8 +528,8 @@ describe(`MultiSelect`, () => {
530528 input . dispatchEvent ( new InputEvent ( `input` ) )
531529 await sleep ( )
532530
533- const li = doc_query ( `div.multiselect ul.options li` )
534- li . dispatchEvent ( new Event ( `mouseup` ) )
531+ const li = doc_query ( `ul.options li` )
532+ li . dispatchEvent ( new MouseEvent ( `mouseup` ) )
535533 await sleep ( )
536534
537535 expect ( input . value ) . toBe ( expected )
0 commit comments