Skip to content

Commit a65e95f

Browse files
Ivan KitanovIvan Kitanov
authored andcommitted
chore(dropdown): Adding test for active descendant
1 parent ac30d52 commit a65e95f

File tree

1 file changed

+30
-5
lines changed

1 file changed

+30
-5
lines changed

projects/igniteui-angular/src/lib/drop-down/drop-down.component.spec.ts

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,13 +1046,9 @@ describe('IgxDropDown ', () => {
10461046
beforeEach(() => {
10471047
fixture = TestBed.createComponent(IgxDropDownTestComponent);
10481048
fixture.detectChanges();
1049-
dropdown = fixture.componentInstance.dropDown;
1049+
dropdown = fixture.componentInstance.dropdown;
10501050
});
10511051
it('should set the aria-label property correctly', () => {
1052-
fixture = TestBed.createComponent(IgxDropDownTestComponent);
1053-
fixture.detectChanges();
1054-
dropdown = fixture.componentInstance.dropdown;
1055-
10561052
// Initially aria-label should be null
10571053
dropdown.toggle();
10581054
fixture.detectChanges();
@@ -1083,6 +1079,35 @@ describe('IgxDropDown ', () => {
10831079
expect(item.getAttribute('aria-label')).toBe(`label ${index}`);
10841080
});
10851081
});
1082+
it('should update aria-activedescendant to the id of the focused item', fakeAsync(() => {
1083+
dropdown.toggle();
1084+
tick();
1085+
fixture.detectChanges();
1086+
1087+
const dropdownElement = fixture.debugElement.query(By.css(`.${CSS_CLASS_DROP_DOWN_BASE}`)).nativeElement;
1088+
let focusedItem = fixture.debugElement.query(By.css(`.${CSS_CLASS_FOCUSED}`)).nativeElement;
1089+
1090+
expect(focusedItem).toBeTruthy();
1091+
let focusedItemId = focusedItem.getAttribute('id');
1092+
expect(focusedItemId).toBeTruthy();
1093+
expect(dropdownElement.getAttribute('aria-activedescendant')).toBe(focusedItemId);
1094+
1095+
dropdown.toggle();
1096+
tick();
1097+
fixture.detectChanges();
1098+
dropdown.toggle();
1099+
tick();
1100+
fixture.detectChanges();
1101+
1102+
UIInteractions.triggerEventHandlerKeyDown('ArrowDown', fixture.debugElement.query(By.css(`.${CSS_CLASS_DROP_DOWN_BASE}`)));
1103+
tick();
1104+
fixture.detectChanges();
1105+
1106+
focusedItem = fixture.debugElement.query(By.css(`.${CSS_CLASS_FOCUSED}`)).nativeElement;
1107+
focusedItemId = focusedItem.getAttribute('id');
1108+
1109+
expect(dropdownElement.getAttribute('aria-activedescendant')).toBe(focusedItemId);
1110+
}));
10861111
});
10871112
describe('Grouped items', () => {
10881113
beforeEach(waitForAsync(() => {

0 commit comments

Comments
 (0)