MCPcopy
hub / github.com/angular/components / runNavigationTests

Function runNavigationTests

src/aria/listbox/listbox.spec.ts:681–864  ·  view source on GitHub ↗
(
    focusMode: 'roving' | 'activedescendant',
    isFocused: (index: number) => boolean,
  )

Source from the content-addressed store, hash-verified

679 });
680
681 function runNavigationTests(
682 focusMode: 'roving' | 'activedescendant',
683 isFocused: (index: number) => boolean,
684 ) {
685 describe(`keyboard navigation (focusMode="${focusMode}")`, () => {
686 it('should move focus to the last focusable option on End', async () => {
687 await setupListbox({focusMode, disabledOptions: [4]});
688 await end();
689 expect(isFocused(4)).toBe(true);
690 });
691
692 it('should move focus to the first focusable option on Home', async () => {
693 await setupListbox({focusMode, disabledOptions: [0]});
694 await end();
695 await home();
696 expect(isFocused(0)).toBe(true);
697 });
698
699 it('should allow keyboard navigation if the group is readonly', async () => {
700 await setupListbox({focusMode, orientation: 'horizontal', readonly: true});
701 await right();
702 expect(isFocused(1)).toBe(true);
703 });
704
705 it('should wrap focus from last to first with ArrowDown when wrap is true (vertical)', async () => {
706 await setupListbox({focusMode, orientation: 'vertical', wrap: true});
707 for (let i = 0; i < optionElements.length - 1; i++) await down();
708 await down();
709 expect(isFocused(0)).toBe(true);
710 });
711
712 it('should not wrap focus from last to first with ArrowDown when wrap is false (vertical)', async () => {
713 await setupListbox({focusMode, orientation: 'vertical', wrap: false});
714 for (let i = 0; i < optionElements.length - 1; i++) await down();
715 await down();
716 expect(isFocused(optionElements.length - 1)).toBe(true);
717 });
718
719 describe('vertical orientation', () => {
720 it('should move focus to the next option on ArrowDown', async () => {
721 await setupListbox({focusMode, orientation: 'vertical'});
722 await down();
723 expect(isFocused(1)).toBe(true);
724 });
725
726 it('should skip disabled options with ArrowDown (softDisabled="false")', async () => {
727 await setupListbox({
728 focusMode,
729 orientation: 'vertical',
730 softDisabled: false,
731 disabledOptions: [1, 2],
732 });
733 await down();
734 expect(isFocused(3)).toBe(true);
735 });
736
737 it('should not skip disabled options with ArrowDown (softDisabled="true")', async () => {
738 await setupListbox({

Callers 1

listbox.spec.tsFile · 0.85

Calls 12

setupListboxFunction · 0.85
endFunction · 0.70
homeFunction · 0.70
rightFunction · 0.70
downFunction · 0.70
leftFunction · 0.70
clickFunction · 0.70
getOptionsFunction · 0.70
typeFunction · 0.70
getAttributeMethod · 0.65
isFocusedFunction · 0.50
valueMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…