@@ -194,7 +194,7 @@ describe('MdSidenav', () => {
194
194
} ) . not . toThrow ( ) ;
195
195
} ) ) ;
196
196
197
- it ( 'should emit the backdrop-clicked event when the backdrop is clicked' , fakeAsync ( ( ) => {
197
+ it ( 'should emit the backdropClick event when the backdrop is clicked' , fakeAsync ( ( ) => {
198
198
let fixture = TestBed . createComponent ( BasicTestApp ) ;
199
199
200
200
let testComponent : BasicTestApp = fixture . debugElement . componentInstance ;
@@ -264,6 +264,54 @@ describe('MdSidenav', () => {
264
264
expect ( testComponent . closeCount ) . toBe ( 1 ) ;
265
265
} ) ) ;
266
266
267
+ it ( 'should not close by pressing escape when disableClose is set' , fakeAsync ( ( ) => {
268
+ let fixture = TestBed . createComponent ( BasicTestApp ) ;
269
+ let testComponent = fixture . debugElement . componentInstance ;
270
+ let sidenav = fixture . debugElement . query ( By . directive ( MdSidenav ) ) . componentInstance ;
271
+
272
+ sidenav . disableClose = true ;
273
+ sidenav . open ( ) ;
274
+
275
+ fixture . detectChanges ( ) ;
276
+ endSidenavTransition ( fixture ) ;
277
+ tick ( ) ;
278
+
279
+ sidenav . handleKeydown ( {
280
+ keyCode : ESCAPE ,
281
+ stopPropagation : ( ) => { }
282
+ } ) ;
283
+
284
+ fixture . detectChanges ( ) ;
285
+ endSidenavTransition ( fixture ) ;
286
+ tick ( ) ;
287
+
288
+ expect ( testComponent . closeCount ) . toBe ( 0 ) ;
289
+ } ) ) ;
290
+
291
+ it ( 'should not close by clicking on the backdrop when disableClose is set' , fakeAsync ( ( ) => {
292
+ let fixture = TestBed . createComponent ( BasicTestApp ) ;
293
+ let testComponent = fixture . debugElement . componentInstance ;
294
+ let sidenav = fixture . debugElement . query ( By . directive ( MdSidenav ) ) . componentInstance ;
295
+
296
+ sidenav . disableClose = true ;
297
+ sidenav . open ( ) ;
298
+
299
+ fixture . detectChanges ( ) ;
300
+ endSidenavTransition ( fixture ) ;
301
+ tick ( ) ;
302
+
303
+ let backdropEl = fixture . debugElement . query ( By . css ( '.md-sidenav-backdrop' ) ) . nativeElement ;
304
+ backdropEl . click ( ) ;
305
+ fixture . detectChanges ( ) ;
306
+ tick ( ) ;
307
+
308
+ fixture . detectChanges ( ) ;
309
+ endSidenavTransition ( fixture ) ;
310
+ tick ( ) ;
311
+
312
+ expect ( testComponent . closeCount ) . toBe ( 0 ) ;
313
+ } ) ) ;
314
+
267
315
it ( 'should restore focus to the trigger element on close' , fakeAsync ( ( ) => {
268
316
let fixture = TestBed . createComponent ( BasicTestApp ) ;
269
317
let sidenav : MdSidenav = fixture . debugElement
@@ -414,7 +462,7 @@ class SidenavContainerTwoSidenavTestApp { }
414
462
/** Test component that contains an MdSidenavContainer and one MdSidenav. */
415
463
@Component ( {
416
464
template : `
417
- <md-sidenav-container (backdrop-clicked )="backdropClicked()">
465
+ <md-sidenav-container (backdropClick )="backdropClicked()">
418
466
<md-sidenav #sidenav align="start"
419
467
(open-start)="openStart()"
420
468
(open)="open()"
0 commit comments