@@ -5,6 +5,15 @@ import {VscodeSingleSelect} from './index.js';
55import { aTimeout , expect , fixture , html } from '@open-wc/testing' ;
66import sinon from 'sinon' ;
77
8+ const ignoredAttributes = [
9+ 'aria-label' ,
10+ 'aria-selected' ,
11+ 'data-filtered-index' ,
12+ 'data-index' ,
13+ 'id' ,
14+ 'role' ,
15+ ] ;
16+
817describe ( 'vscode-single-select' , ( ) => {
918 it ( 'is defined' , ( ) => {
1019 const el = document . createElement ( 'vscode-single-select' ) ;
@@ -433,31 +442,22 @@ describe('vscode-single-select', () => {
433442
434443 const dropdown = el . shadowRoot ?. querySelector ( '.dropdown' ) ;
435444
436- expect ( dropdown ) . lightDom . to . eq ( `
445+ expect ( dropdown ) . lightDom . to . eq (
446+ `
437447 <ul class="options">
438- <li
439- class="option"
440- data-filtered-index="0"
441- data-index="0"
442- >
448+ <li class="option">
443449 <b>A</b>ntig<b>u</b>a and Barbuda
444450 </li>
445- <li
446- class="option"
447- data-filtered-index="1"
448- data-index="3"
449- >
451+ <li class="option">
450452 <b>A</b><b>u</b>stralia
451453 </li>
452- <li
453- class="option"
454- data-filtered-index="2"
455- data-index="4"
456- >
454+ <li class="option">
457455 <b>A</b><b>u</b>stria
458456 </li>
459457 </ul>
460- ` ) ;
458+ ` ,
459+ { ignoreAttributes : ignoredAttributes }
460+ ) ;
461461 expect ( dropdown ?. classList . contains ( 'open' ) ) . to . be . true ;
462462 } ) ;
463463
@@ -488,7 +488,7 @@ describe('vscode-single-select', () => {
488488 <li class="option">App<b>l</b><b>e</b></li>
489489 <li class="option active"><b>L</b><b>e</b>mon</li>
490490 ` ,
491- { ignoreAttributes : [ 'data-filtered-index' , 'data-index' ] }
491+ { ignoreAttributes : ignoredAttributes }
492492 ) ;
493493 } ) ;
494494
@@ -673,13 +673,16 @@ describe('vscode-single-select', () => {
673673
674674 const dropdown = el . shadowRoot ?. querySelector ( '.dropdown' ) ;
675675
676- expect ( dropdown ) . lightDom . to . eq ( `
676+ expect ( dropdown ) . lightDom . to . eq (
677+ `
677678 <ul class="options">
678679 <li class="no-options">
679680 No options
680681 </li>
681682 </ul>
682- ` ) ;
683+ ` ,
684+ { ignoreAttributes : ignoredAttributes }
685+ ) ;
683686 } ) ;
684687
685688 it ( 'shows suggested option below the options' , async ( ) => {
@@ -691,8 +694,8 @@ describe('vscode-single-select', () => {
691694 </ vscode-single-select >
692695 ` ) ) as VscodeSingleSelect ;
693696
694- el . shadowRoot ?. querySelector ( '.combobox-input' ) ;
695- await clickOnElement ( el ) ;
697+ el . focus ( ) ;
698+ await el . updateComplete ;
696699 await sendKeys ( { type : 'lo' } ) ;
697700
698701 const dropdown = el . shadowRoot ?. querySelector ( '.dropdown' ) ;
@@ -710,7 +713,14 @@ describe('vscode-single-select', () => {
710713 </ul>
711714 ` ,
712715 {
713- ignoreAttributes : [ 'data-filtered-index' , 'data-index' ] ,
716+ ignoreAttributes : [
717+ 'aria-label' ,
718+ 'aria-selected' ,
719+ 'data-filtered-index' ,
720+ 'data-index' ,
721+ 'id' ,
722+ 'role' ,
723+ ] ,
714724 }
715725 ) ;
716726 } ) ;
@@ -724,25 +734,31 @@ describe('vscode-single-select', () => {
724734 </ vscode-single-select >
725735 ` ) ) as VscodeSingleSelect ;
726736
727- el . shadowRoot ?. querySelector ( '.combobox-input' ) ;
728- await clickOnElement ( el ) ;
737+ el . focus ( ) ;
738+ await el . updateComplete ;
729739 await sendKeys ( { type : 'Sit' } ) ;
730740
731741 const dropdown = el . shadowRoot ?. querySelector ( '.dropdown' ) ;
732742
733743 expect ( dropdown ) . lightDom . to . eq (
734744 `
735- <ul class="options">
736- <li class="option placeholder">Add "Sit"</li>
737- </ul>
738- ` ,
745+ <ul class="options">
746+ <li class="option placeholder">Add "Sit"</li>
747+ </ul>
748+ ` ,
739749 {
740- ignoreAttributes : [ 'data-filtered-index' , 'data-index' ] ,
750+ ignoreAttributes : [
751+ 'aria-label' ,
752+ 'data-filtered-index' ,
753+ 'data-index' ,
754+ 'id' ,
755+ 'role' ,
756+ ] ,
741757 }
742758 ) ;
743759 } ) ;
744760
745- it . only ( 'selects the suggested option' , async ( ) => {
761+ it ( 'selects the suggested option' , async ( ) => {
746762 const el = ( await fixture ( html `
747763 < vscode-single-select combobox creatable >
748764 < vscode-option > Lorem</ vscode-option >
@@ -751,8 +767,6 @@ describe('vscode-single-select', () => {
751767 </ vscode-single-select >
752768 ` ) ) as VscodeSingleSelect ;
753769
754- // el.shadowRoot?.querySelector('.combobox-input');
755-
756770 el . focus ( ) ;
757771 await el . updateComplete ;
758772 await sendKeys ( { type : 'dol' } ) ;
@@ -793,8 +807,8 @@ describe('vscode-single-select', () => {
793807 const spy = sinon . spy ( ) ;
794808 el . addEventListener ( 'vsc-single-select-create-option' , spy ) ;
795809
796- el . shadowRoot ?. querySelector ( '.combobox-input' ) ;
797- await clickOnElement ( el ) ;
810+ el . focus ( ) ;
811+ await el . updateComplete ;
798812 await sendKeys ( { type : 'Sit' } ) ;
799813
800814 await sendKeys ( { down : 'ArrowDown' } ) ;
0 commit comments