Skip to content

Commit 35f3787

Browse files
committed
test(IgxCalendar): verify that tabIndex is applied correctly #6275
1 parent 4c66da6 commit 35f3787

File tree

1 file changed

+48
-3
lines changed

1 file changed

+48
-3
lines changed

Diff for: projects/igniteui-angular/src/lib/calendar/calendar-multi-view.component.spec.ts

+48-3
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,45 @@ describe('Multi-View Calendar - ', () => {
554554
HelperTestFunctions.verifyCalendarSubHeaders(fixture, [march2020, april2020, may2020]);
555555
}));
556556

557+
it('Verify tabindex is correct when navigating with arrow keys', fakeAsync(() => {
558+
calendar.hideOutsideDays = true;
559+
fixture.detectChanges();
560+
561+
let dates = HelperTestFunctions.getMonthViewDates(fixture, 0);
562+
UIInteractions.simulateClickEvent(dates[0]);
563+
fixture.detectChanges();
564+
tick();
565+
566+
UIInteractions.triggerKeyDownEvtUponElem('ArrowDown', dates[0]);
567+
fixture.detectChanges();
568+
tick();
569+
dates = HelperTestFunctions.getMonthViewDates(fixture, 0);
570+
expect(document.activeElement).toEqual(dates[7]);
571+
expect(dates[7].tabIndex).toBe(0);
572+
573+
UIInteractions.triggerKeyDownEvtUponElem('ArrowUp', dates[7]);
574+
fixture.detectChanges();
575+
tick();
576+
dates = HelperTestFunctions.getMonthViewDates(fixture, 0);
577+
expect(document.activeElement).toEqual(dates[0]);
578+
expect(dates[0].tabIndex).toBe(0);
579+
580+
UIInteractions.triggerKeyDownEvtUponElem('ArrowRight', dates[0]);
581+
fixture.detectChanges();
582+
tick();
583+
dates = HelperTestFunctions.getMonthViewDates(fixture, 0);
584+
expect(document.activeElement).toEqual(dates[1]);
585+
expect(dates[1].tabIndex).toBe(0);
586+
587+
UIInteractions.triggerKeyDownEvtUponElem('ArrowLeft', dates[1]);
588+
fixture.detectChanges();
589+
tick();
590+
dates = HelperTestFunctions.getMonthViewDates(fixture, 0);
591+
expect(document.activeElement).toEqual(dates[0]);
592+
expect(dates[0].tabIndex).toBe(0);
593+
}));
594+
595+
557596
it('Verify navigation with pageUp', fakeAsync(() => {
558597
let monthDates = HelperTestFunctions.getMonthViewDates(fixture, 1);
559598
UIInteractions.simulateClickEvent(monthDates[16]);
@@ -694,17 +733,19 @@ describe('Multi-View Calendar - ', () => {
694733
fixture.detectChanges();
695734
inactiveDates = HelperTestFunctions.getMonthViewInactiveDates(fixture, 0);
696735
inactiveDates.forEach(date => {
697-
expect(date.tabIndex).toEqual(0);
736+
expect(date.tabIndex).toEqual(-1);
698737
});
699738

700739
monthDates = HelperTestFunctions.getMonthViewDates(fixture, 0);
701740
for (let index = 6; index < 14; index++) {
702-
expect(monthDates[index].tabIndex).toEqual(0);
741+
expect(monthDates[index].tabIndex).toEqual(-1);
703742

704743
}
744+
745+
expect(monthDates[0].tabIndex).toEqual(0);
705746
}));
706747

707-
it('Verify navigation with Home and End keys', fakeAsync(() => {
748+
it('Verify navigation with Home and End keys and check the tabindex', fakeAsync(() => {
708749
let monthDates = HelperTestFunctions.getMonthViewDates(fixture, 1);
709750
UIInteractions.simulateClickEvent(monthDates[16]);
710751
fixture.detectChanges();
@@ -716,13 +757,17 @@ describe('Multi-View Calendar - ', () => {
716757

717758
monthDates = HelperTestFunctions.getMonthViewDates(fixture, 0);
718759
expect(document.activeElement).toEqual(monthDates[0]);
760+
expect(monthDates[0].tabIndex).toEqual(0);
761+
719762

720763
UIInteractions.triggerKeyDownEvtUponElem('End', monthDates[0], true);
721764
fixture.detectChanges();
722765
tick();
723766

724767
monthDates = HelperTestFunctions.getMonthViewDates(fixture, 2);
725768
expect(document.activeElement).toEqual(monthDates[monthDates.length - 1]);
769+
expect(monthDates[monthDates.length - 1].tabIndex).toEqual(0);
770+
726771
}));
727772

728773
it('Verify navigation with Home and End keys when there are disabled dates', fakeAsync(() => {

0 commit comments

Comments
 (0)