|
4 | 4 | import {Component, ViewChild, ViewContainerRef} from '@angular/core';
|
5 | 5 | import {CommonModule} from '@angular/common';
|
6 | 6 | import {By} from '@angular/platform-browser';
|
7 |
| -import {ENTER, LEFT_ARROW, RIGHT_ARROW} from '@angular/cdk/keycodes'; |
| 7 | +import {ENTER, LEFT_ARROW, RIGHT_ARROW, SPACE} from '@angular/cdk/keycodes'; |
8 | 8 | import {PortalModule} from '@angular/cdk/portal';
|
9 | 9 | import {ViewportRuler} from '@angular/cdk/overlay';
|
10 | 10 | import {Direction, Directionality} from '@angular/cdk/bidi';
|
@@ -120,14 +120,22 @@ describe('MdTabHeader', () => {
|
120 | 120 |
|
121 | 121 | // Select the focused index 2
|
122 | 122 | expect(appComponent.selectedIndex).toBe(0);
|
123 |
| - dispatchKeyboardEvent(tabListContainer, 'keydown', ENTER); |
| 123 | + const enterEvent = dispatchKeyboardEvent(tabListContainer, 'keydown', ENTER); |
124 | 124 | fixture.detectChanges();
|
125 | 125 | expect(appComponent.selectedIndex).toBe(2);
|
| 126 | + expect(enterEvent.defaultPrevented).toBe(true); |
126 | 127 |
|
127 | 128 | // Move focus right to 0
|
128 | 129 | dispatchKeyboardEvent(tabListContainer, 'keydown', LEFT_ARROW);
|
129 | 130 | fixture.detectChanges();
|
130 | 131 | expect(appComponent.mdTabHeader.focusIndex).toBe(0);
|
| 132 | + |
| 133 | + // Select the focused 0 using space. |
| 134 | + expect(appComponent.selectedIndex).toBe(2); |
| 135 | + const spaceEvent = dispatchKeyboardEvent(tabListContainer, 'keydown', SPACE); |
| 136 | + fixture.detectChanges(); |
| 137 | + expect(appComponent.selectedIndex).toBe(0); |
| 138 | + expect(spaceEvent.defaultPrevented).toBe(true); |
131 | 139 | });
|
132 | 140 | });
|
133 | 141 |
|
|
0 commit comments