|
1 |
| -import {ENTER, ESCAPE, RIGHT_ARROW} from '@angular/cdk/keycodes'; |
| 1 | +import {ENTER, ESCAPE, RIGHT_ARROW, UP_ARROW} from '@angular/cdk/keycodes'; |
2 | 2 | import {Overlay, OverlayContainer, ScrollDispatcher} from '@angular/cdk/overlay';
|
3 |
| -import {dispatchFakeEvent, dispatchKeyboardEvent, dispatchMouseEvent} from '@angular/cdk/testing'; |
| 3 | +import { |
| 4 | + dispatchFakeEvent, |
| 5 | + dispatchKeyboardEvent, |
| 6 | + dispatchMouseEvent, |
| 7 | + createKeyboardEvent, |
| 8 | + dispatchEvent, |
| 9 | +} from '@angular/cdk/testing'; |
4 | 10 | import {Component, ViewChild} from '@angular/core';
|
5 | 11 | import {ComponentFixture, fakeAsync, flush, inject, TestBed} from '@angular/core/testing';
|
6 | 12 | import {FormControl, FormsModule, ReactiveFormsModule} from '@angular/forms';
|
@@ -386,6 +392,25 @@ describe('MatDatepicker', () => {
|
386 | 392 | expect(testComponent.datepicker.opened).toBe(false);
|
387 | 393 | }))
|
388 | 394 | );
|
| 395 | + |
| 396 | + it('should close the datpeicker using ALT + UP_ARROW', fakeAsync(() => { |
| 397 | + testComponent.datepicker.open(); |
| 398 | + fixture.detectChanges(); |
| 399 | + flush(); |
| 400 | + |
| 401 | + expect(testComponent.datepicker.opened).toBe(true); |
| 402 | + |
| 403 | + const content = document.querySelector('.mat-datepicker-content')!; |
| 404 | + const event = createKeyboardEvent('keydown', UP_ARROW); |
| 405 | + Object.defineProperty(event, 'altKey', {get: () => true}); |
| 406 | + |
| 407 | + dispatchEvent(content, event); |
| 408 | + fixture.detectChanges(); |
| 409 | + flush(); |
| 410 | + |
| 411 | + expect(testComponent.datepicker.opened).toBe(false); |
| 412 | + })); |
| 413 | + |
389 | 414 | });
|
390 | 415 |
|
391 | 416 | describe('datepicker with too many inputs', () => {
|
|
0 commit comments