@@ -102,6 +102,18 @@ describe('MdDrawer', () => {
102102 expect ( testComponent . backdropClickedCount ) . toBe ( 1 ) ;
103103 } ) ) ;
104104
105+ it ( 'should emit the escapeKeydown event when ESCAPE key is pressed' , ( ) => {
106+ let fixture = TestBed . createComponent ( BasicTestApp ) ;
107+ let testComponent : BasicTestApp = fixture . debugElement . componentInstance ;
108+ let drawer = fixture . debugElement . query ( By . directive ( MdDrawer ) ) ;
109+ expect ( testComponent . escapeKeydownCount ) . toBe ( 0 ) ;
110+
111+ dispatchKeyboardEvent ( drawer . nativeElement , 'keydown' , ESCAPE ) ;
112+ fixture . detectChanges ( ) ;
113+
114+ expect ( testComponent . escapeKeydownCount ) . toBe ( 1 ) ;
115+ } ) ;
116+
105117 it ( 'should close when pressing escape' , fakeAsync ( ( ) => {
106118 let fixture = TestBed . createComponent ( BasicTestApp ) ;
107119
@@ -386,7 +398,8 @@ class DrawerContainerTwoDrawerTestApp {
386398 <md-drawer-container (backdropClick)="backdropClicked()">
387399 <md-drawer #drawer position="start"
388400 (open)="open()"
389- (close)="close()">
401+ (close)="close()"
402+ (escapeKeydown)="escapeKeydown()">
390403 <button #drawerButton>Content.</button>
391404 </md-drawer>
392405 <button (click)="drawer.open()" class="open" #openButton></button>
@@ -397,6 +410,7 @@ class BasicTestApp {
397410 openCount : number = 0 ;
398411 closeCount : number = 0 ;
399412 backdropClickedCount : number = 0 ;
413+ escapeKeydownCount : number = 0 ;
400414
401415 @ViewChild ( 'drawerButton' ) drawerButton : ElementRef ;
402416 @ViewChild ( 'openButton' ) openButton : ElementRef ;
@@ -413,6 +427,10 @@ class BasicTestApp {
413427 backdropClicked ( ) {
414428 this . backdropClickedCount ++ ;
415429 }
430+
431+ escapeKeydown ( ) {
432+ this . escapeKeydownCount ++ ;
433+ }
416434}
417435
418436@Component ( {
0 commit comments