@@ -3,7 +3,7 @@ import {By} from '@angular/platform-browser';
3
3
import { ComponentFixture , TestBed , async , inject } from '@angular/core/testing' ;
4
4
import { Directionality } from '@angular/cdk/bidi' ;
5
5
import { dispatchKeyboardEvent } from '@angular/cdk/testing' ;
6
- import { ESCAPE } from '@angular/cdk/keycodes' ;
6
+ import { ESCAPE , A } from '@angular/cdk/keycodes' ;
7
7
import { CdkConnectedOverlay , OverlayModule , CdkOverlayOrigin } from './index' ;
8
8
import { OverlayContainer } from './overlay-container' ;
9
9
import {
@@ -447,6 +447,18 @@ describe('Overlay directives', () => {
447
447
expect ( fixture . componentInstance . detachHandler ) . toHaveBeenCalled ( ) ;
448
448
} ) ;
449
449
450
+ it ( 'should emit the keydown events from the overlay' , ( ) => {
451
+ expect ( fixture . componentInstance . keydownHandler ) . not . toHaveBeenCalled ( ) ;
452
+
453
+ fixture . componentInstance . isOpen = true ;
454
+ fixture . detectChanges ( ) ;
455
+
456
+ const event = dispatchKeyboardEvent ( document . body , 'keydown' , A ) ;
457
+ fixture . detectChanges ( ) ;
458
+
459
+ expect ( fixture . componentInstance . keydownHandler ) . toHaveBeenCalledWith ( event ) ;
460
+ } ) ;
461
+
450
462
} ) ;
451
463
452
464
} ) ;
@@ -474,6 +486,7 @@ describe('Overlay directives', () => {
474
486
(positionChange)="positionChangeHandler($event)"
475
487
(attach)="attachHandler()"
476
488
(detach)="detachHandler()"
489
+ (keydownEvents)="keydownHandler($event)"
477
490
[cdkConnectedOverlayMinWidth]="minWidth"
478
491
[cdkConnectedOverlayMinHeight]="minHeight"
479
492
[cdkConnectedOverlayPositions]="positionOverrides">
@@ -499,7 +512,8 @@ class ConnectedOverlayDirectiveTest {
499
512
growAfterOpen : boolean ;
500
513
push : boolean ;
501
514
backdropClickHandler = jasmine . createSpy ( 'backdropClick handler' ) ;
502
- positionChangeHandler = jasmine . createSpy ( 'positionChangeHandler' ) ;
515
+ positionChangeHandler = jasmine . createSpy ( 'positionChange handler' ) ;
516
+ keydownHandler = jasmine . createSpy ( 'keydown handler' ) ;
503
517
positionOverrides : ConnectionPositionPair [ ] ;
504
518
attachHandler = jasmine . createSpy ( 'attachHandler' ) . and . callFake ( ( ) => {
505
519
this . attachResult =
0 commit comments