@@ -258,7 +258,6 @@ describe('vscode-single-select', () => {
258258
259259 //#region keyboard interactions
260260
261-
262261 it ( 'the value should be changed when the arrow down key pressed while the dropdown is closed' , async ( ) => {
263262 const el = ( await fixture ( html `
264263 < vscode-single-select >
@@ -831,54 +830,13 @@ describe('vscode-single-select', () => {
831830 </ vscode-single-select >
832831 ` ) ) as VscodeSingleSelect ;
833832
834- // selects the first option
835- await clickOnElement ( el ) ;
836- let options = el . shadowRoot ?. querySelector ( '.options' ) ;
837- const firstOption = options ?. querySelector ( 'li' ) ! ;
838- await clickOnElement ( firstOption ) ;
839-
840- expect ( el . value ) . to . eq ( 'Lorem' ) ;
841-
842- // re-opens the dropdown, selects the second option with keyboard
843- await clickOnElement ( el ) ;
844- await sendKeys ( { down : 'ArrowDown' } ) ;
845-
846- expect ( el . shadowRoot ?. querySelector ( '.dropdown' ) ) . lightDom . to . eq (
847- `
848- <ul class="options">
849- <li class="option">Lorem</li>
850- <li class="active option">Ipsum</li>
851- <li class="option">Dolor</li>
852- </ul>
853- ` ,
854- {
855- ignoreAttributes : [
856- 'aria-selected' ,
857- 'data-index' ,
858- 'data-filtered-index' ,
859- 'id' ,
860- 'role' ,
861- ] ,
862- }
863- ) ;
833+ el . value = 'Ipsum' ;
834+ await el . updateComplete ;
864835
865- // clicks outside, closes the dropdown
866- await sendMouse ( { type : 'click' , position : [ 500 , 500 ] } ) ;
867- // opens the dropdown again
868836 await clickOnElement ( el ) ;
837+ const activeOption = el . shadowRoot ?. querySelector ( '.option.active' ) ;
869838
870- expect ( el . shadowRoot ?. querySelector ( '.dropdown' ) ) . lightDom . to . eq (
871- `
872- <ul class="options">
873- <li class="active option">Lorem</li>
874- <li class="option">Ipsum</li>
875- <li class="option">Dolor</li>
876- </ul>
877- ` ,
878- {
879- ignoreAttributes : [ 'data-index' , 'data-filtered-index' ] ,
880- }
881- ) ;
839+ expect ( activeOption ) . lightDom . to . eq ( 'Ipsum' ) ;
882840 } ) ;
883841
884842 //#region keyboard interactions
@@ -887,7 +845,25 @@ describe('vscode-single-select', () => {
887845 it (
888846 'when the ESC key is pressed, clears the textbox if the listbox is not displayed'
889847 ) ;
890- it ( 'when the ArrowDown key is pressed selects the next option in a filtered list' ) ;
848+
849+ it ( 'when the ArrowDown key is pressed selects the next option in a filtered list' , async ( ) => {
850+ const el = await fixture < VscodeSingleSelect > (
851+ html `< vscode-single-select combobox >
852+ < vscode-option > Lorem</ vscode-option >
853+ < vscode-option > Ipsum</ vscode-option >
854+ < vscode-option > Dolor</ vscode-option >
855+ </ vscode-single-select > `
856+ ) ;
857+
858+ el . focus ( ) ;
859+ await sendKeys ( { type : 'l' } ) ;
860+ await sendKeys ( { down : 'ArrowDown' } ) ;
861+ await sendKeys ( { down : 'ArrowDown' } ) ;
862+
863+ const activeOption = el . shadowRoot ?. querySelector ( '.option.active' ) ;
864+
865+ expect ( activeOption ) . lightDom . to . eq ( 'Do<b>l</b>or' ) ;
866+ } ) ;
891867 //#endregion
892868 //#endregion
893869 } ) ;
@@ -1093,7 +1069,7 @@ describe('vscode-single-select', () => {
10931069 } ) ;
10941070
10951071 it ( 'skips disabled options' , async ( ) => {
1096- const el = await fixture ( html `
1072+ const el = await fixture < VscodeSingleSelect > ( html `
10971073 < vscode-single-select >
10981074 < vscode-option > Lorem</ vscode-option >
10991075 < vscode-option disabled > Ipsum</ vscode-option >
@@ -1102,13 +1078,13 @@ describe('vscode-single-select', () => {
11021078 </ vscode-single-select >
11031079 ` ) ;
11041080
1105- await clickOnElement ( el ) ;
1106- await clickOnElement ( el ) ;
1107- await sendKeys ( { down : 'ArrowDown' } ) ;
1081+ el . focus ( ) ;
1082+ await sendKeys ( { press : 'ArrowDown' } ) ;
1083+ await sendKeys ( { press : 'ArrowDown' } ) ;
11081084
1109- const text = el . shadowRoot ?. querySelector ( '.text ' ) ;
1085+ const activeOption = el . shadowRoot ?. querySelector ( '.option.active ' ) ;
11101086
1111- expect ( text ) . lightDom . to . eq ( 'Sit' ) ;
1087+ expect ( activeOption ) . lightDom . to . eq ( 'Sit' ) ;
11121088 } ) ;
11131089
11141090 it ( 'skips disabled options when dropdown is open' , async ( ) => {
@@ -1235,7 +1211,9 @@ describe('vscode-single-select', () => {
12351211 } ) ;
12361212
12371213 describe ( 'closed dropdown' , ( ) => {
1238- it ( 'opens the dropdown if it is not already displayed when DownArrow is pressed' ) ;
1214+ it (
1215+ 'opens the dropdown if it is not already displayed when DownArrow is pressed'
1216+ ) ;
12391217 it ( 'opens the dropdown when Alt + DownArrow are pressed' ) ;
12401218 it ( 'Up Arrow is pressed' ) ;
12411219 it ( 'Enter is pressed' ) ;
0 commit comments