@@ -1034,6 +1034,56 @@ describe('IgxDropDown ', () => {
1034
1034
} ) ;
1035
1035
} ) ;
1036
1036
describe ( 'Rendering' , ( ) => {
1037
+ describe ( 'Accessibility' , ( ) => {
1038
+ beforeEach ( waitForAsync ( ( ) => {
1039
+ TestBed . configureTestingModule ( {
1040
+ imports : [
1041
+ NoopAnimationsModule ,
1042
+ IgxDropDownTestComponent ,
1043
+ ]
1044
+ } ) . compileComponents ( ) ;
1045
+ } ) ) ;
1046
+ beforeEach ( ( ) => {
1047
+ fixture = TestBed . createComponent ( IgxDropDownTestComponent ) ;
1048
+ fixture . detectChanges ( ) ;
1049
+ dropdown = fixture . componentInstance . dropDown ;
1050
+ } ) ;
1051
+ it ( 'should set the aria-label property correctly' , ( ) => {
1052
+ fixture = TestBed . createComponent ( IgxDropDownTestComponent ) ;
1053
+ fixture . detectChanges ( ) ;
1054
+ dropdown = fixture . componentInstance . dropdown ;
1055
+
1056
+ // Initially aria-label should be null
1057
+ dropdown . toggle ( ) ;
1058
+ fixture . detectChanges ( ) ;
1059
+ let items = document . querySelectorAll ( `.${ CSS_CLASS_ITEM } ` ) ;
1060
+ items . forEach ( item => {
1061
+ expect ( item . getAttribute ( 'aria-label' ) ) . toBeNull ( ) ;
1062
+ } ) ;
1063
+
1064
+ // Set value and check if aria-label reflects it
1065
+ dropdown . toggle ( ) ;
1066
+ fixture . detectChanges ( ) ;
1067
+ dropdown . items . forEach ( ( item , index ) => item . value = `value ${ index } ` ) ;
1068
+ dropdown . toggle ( ) ;
1069
+ fixture . detectChanges ( ) ;
1070
+ items = document . querySelectorAll ( `.${ CSS_CLASS_ITEM } ` ) ;
1071
+ items . forEach ( ( item , index ) => {
1072
+ expect ( item . getAttribute ( 'aria-label' ) ) . toBe ( `value ${ index } ` ) ;
1073
+ } ) ;
1074
+
1075
+ // Phase 3: Set explicit ariaLabel and verify it overrides value
1076
+ dropdown . toggle ( ) ;
1077
+ fixture . detectChanges ( ) ;
1078
+ dropdown . items . forEach ( ( item , index ) => item . ariaLabel = `label ${ index } ` ) ;
1079
+ dropdown . toggle ( ) ;
1080
+ fixture . detectChanges ( ) ;
1081
+ items = document . querySelectorAll ( `.${ CSS_CLASS_ITEM } ` ) ;
1082
+ items . forEach ( ( item , index ) => {
1083
+ expect ( item . getAttribute ( 'aria-label' ) ) . toBe ( `label ${ index } ` ) ;
1084
+ } ) ;
1085
+ } ) ;
1086
+ } ) ;
1037
1087
describe ( 'Grouped items' , ( ) => {
1038
1088
beforeEach ( waitForAsync ( ( ) => {
1039
1089
TestBed . configureTestingModule ( {
0 commit comments