@@ -216,6 +216,11 @@ describe('vscode-single-select', () => {
216216 ` ) ) as VscodeSingleSelect ;
217217
218218 el . value = 'Lorem' ;
219+
220+ // first arrow down press opens the dropdown
221+ el . dispatchEvent ( new KeyboardEvent ( 'keydown' , { key : 'ArrowDown' } ) ) ;
222+ await el . updateComplete ;
223+
219224 el . dispatchEvent ( new KeyboardEvent ( 'keydown' , { key : 'ArrowDown' } ) ) ;
220225 await el . updateComplete ;
221226
@@ -227,7 +232,7 @@ describe('vscode-single-select', () => {
227232 el . dispatchEvent ( new KeyboardEvent ( 'keydown' , { key : 'ArrowDown' } ) ) ;
228233 await el . updateComplete ;
229234 } ) . not . throw ( ) ;
230- expect ( el . value ) . to . eq ( 'Ipsum ' ) ;
235+ expect ( el . value ) . to . eq ( 'Lorem ' ) ;
231236 } ) ;
232237
233238 it ( 'dropdown should be scrolled to the selected option' , async ( ) => {
@@ -255,11 +260,10 @@ describe('vscode-single-select', () => {
255260 < vscode-option > Bhutan</ vscode-option >
256261 </ vscode-single-select >
257262 ` ) ) as VscodeSingleSelect ;
258- await el . updateComplete ;
259263
260- const face = el . shadowRoot ?. querySelector ( '.select-face' ) ;
261- face ?. dispatchEvent ( new MouseEvent ( 'click' ) ) ;
264+ el . focus ( ) ;
262265 await el . updateComplete ;
266+ await sendKeys ( { press : 'Enter' } ) ;
263267
264268 const options = el . shadowRoot ?. querySelector ( '.options' ) ;
265269 expect ( options ?. scrollTop ) . to . eq ( 220 ) ;
@@ -553,14 +557,10 @@ describe('vscode-single-select', () => {
553557 el . dispatchEvent ( new KeyboardEvent ( 'keydown' , { key : 'Enter' } ) ) ;
554558 await el . updateComplete ;
555559
556- const dispatchedChangeEvent = spy . args [ 2 ] [ 0 ] as CustomEvent ;
560+ const dispatchedChangeEvent = spy . args [ 2 ] [ 0 ] as Event ;
557561
558562 expect ( el . value ) . to . eq ( 'Antigua and Barbuda' ) ;
559- expect ( dispatchedChangeEvent . type ) . to . eq ( 'vsc-change' ) ;
560- expect ( dispatchedChangeEvent . detail ) . to . eql ( {
561- selectedIndex : 0 ,
562- value : 'Antigua and Barbuda' ,
563- } ) ;
563+ expect ( dispatchedChangeEvent . type ) . to . eq ( 'change' ) ;
564564 } ) ;
565565
566566 it ( 'select an option with the arrow down key, opens the dropdown with the enter key, scroll to the selected option' , async ( ) => {
@@ -616,16 +616,16 @@ describe('vscode-single-select', () => {
616616 el . dispatchEvent ( new KeyboardEvent ( 'keydown' , { key : 'ArrowDown' } ) ) ;
617617 await el . updateComplete ;
618618
619- el . dispatchEvent ( new KeyboardEvent ( 'keydown' , { key : 'Enter' } ) ) ;
619+ await sendKeys ( { down : 'Enter' } ) ;
620620 await el . updateComplete ;
621621
622622 const activeOpt = el . shadowRoot ?. querySelector ( '.option.active' ) ;
623623 const optionsEl = el . shadowRoot ?. querySelector ( '.options' ) ;
624624
625625 expect ( input . value ) . to . eq ( 'Austria' ) ;
626626 expect ( activeOpt ) . not . null ;
627- expect ( ( activeOpt as HTMLLIElement ) . innerText ) . to . eq ( 'Austria' ) ;
628- expect ( optionsEl ?. scrollTop ) . to . eq ( 198 ) ;
627+ expect ( activeOpt as HTMLLIElement ) . lightDom . to . eq ( 'Austria' ) ;
628+ expect ( optionsEl ?. scrollTop ) . to . eq ( 0 ) ;
629629 expect ( el . value ) . to . eq ( 'Austria' ) ;
630630 expect ( el . selectedIndex ) . to . eq ( 9 ) ;
631631 } ) ;
0 commit comments