@@ -190,6 +190,49 @@ describe('MdSidenav', () => {
190
190
tick ( ) ;
191
191
} ) . not . toThrow ( ) ;
192
192
} ) ) ;
193
+
194
+ it ( 'should emit the backdrop-clicked event when the backdrop is clicked' , fakeAsync ( ( ) => {
195
+ let fixture = TestBed . createComponent ( BasicTestApp ) ;
196
+
197
+ let testComponent : BasicTestApp = fixture . debugElement . componentInstance ;
198
+ let openButtonElement = fixture . debugElement . query ( By . css ( '.open' ) ) ;
199
+ openButtonElement . nativeElement . click ( ) ;
200
+ fixture . detectChanges ( ) ;
201
+ tick ( ) ;
202
+
203
+ endSidenavTransition ( fixture ) ;
204
+ tick ( ) ;
205
+
206
+ expect ( testComponent . backdropClickedCount ) . toBe ( 0 ) ;
207
+
208
+ let sidenavBackdropElement = fixture . debugElement . query ( By . css ( '.md-sidenav-backdrop' ) ) ;
209
+ sidenavBackdropElement . nativeElement . click ( ) ;
210
+ fixture . detectChanges ( ) ;
211
+ tick ( ) ;
212
+
213
+ expect ( testComponent . backdropClickedCount ) . toBe ( 1 ) ;
214
+
215
+ endSidenavTransition ( fixture ) ;
216
+ tick ( ) ;
217
+
218
+ openButtonElement . nativeElement . click ( ) ;
219
+ fixture . detectChanges ( ) ;
220
+ tick ( ) ;
221
+
222
+ endSidenavTransition ( fixture ) ;
223
+ tick ( ) ;
224
+
225
+ let closeButtonElement = fixture . debugElement . query ( By . css ( '.close' ) ) ;
226
+ closeButtonElement . nativeElement . click ( ) ;
227
+ fixture . detectChanges ( ) ;
228
+ tick ( ) ;
229
+
230
+ endSidenavTransition ( fixture ) ;
231
+ tick ( ) ;
232
+
233
+ expect ( testComponent . backdropClickedCount ) . toBe ( 1 ) ;
234
+ } ) ) ;
235
+
193
236
} ) ;
194
237
195
238
describe ( 'attributes' , ( ) => {
@@ -267,7 +310,7 @@ class SidenavLayoutTwoSidenavTestApp { }
267
310
/** Test component that contains an MdSidenavLayout and one MdSidenav. */
268
311
@Component ( {
269
312
template : `
270
- <md-sidenav-layout>
313
+ <md-sidenav-layout (backdrop-clicked)="backdropClicked()" >
271
314
<md-sidenav #sidenav align="start"
272
315
(open-start)="openStart()"
273
316
(open)="open()"
@@ -284,6 +327,7 @@ class BasicTestApp {
284
327
openCount : number = 0 ;
285
328
closeStartCount : number = 0 ;
286
329
closeCount : number = 0 ;
330
+ backdropClickedCount : number = 0 ;
287
331
288
332
openStart ( ) {
289
333
this . openStartCount ++ ;
@@ -300,6 +344,10 @@ class BasicTestApp {
300
344
close ( ) {
301
345
this . closeCount ++ ;
302
346
}
347
+
348
+ backdropClicked ( ) {
349
+ this . backdropClickedCount ++ ;
350
+ }
303
351
}
304
352
305
353
@Component ( {
0 commit comments