@@ -384,6 +384,22 @@ describe('MatMonthView', () => {
384
384
expect ( fixture . componentInstance . selectedChangeSpy ) . toHaveBeenCalledWith ( selectedDate ) ;
385
385
} ) ;
386
386
387
+ it ( 'should fire the _userSelection event with the correct value when clicking ' +
388
+ 'on a selected date' , ( ) => {
389
+ const date = new Date ( 2017 , JAN , 10 ) ;
390
+ testComponent . selected = date ;
391
+ fixture . detectChanges ( ) ;
392
+
393
+ expect ( fixture . componentInstance . userSelectionSpy ) . not . toHaveBeenCalled ( ) ;
394
+
395
+ const selectedCell =
396
+ monthViewNativeElement . querySelector ( '.mat-calendar-body-selected' ) as HTMLElement ;
397
+ selectedCell . click ( ) ;
398
+ fixture . detectChanges ( ) ;
399
+
400
+ expect ( fixture . componentInstance . userSelectionSpy ) . toHaveBeenCalledWith (
401
+ jasmine . objectContaining ( { value : date } ) ) ;
402
+ } ) ;
387
403
} ) ;
388
404
} ) ;
389
405
} ) ;
@@ -449,12 +465,14 @@ describe('MatMonthView', () => {
449
465
<mat-month-view
450
466
[(activeDate)]="date"
451
467
[(selected)]="selected"
452
- (selectedChange)="selectedChangeSpy($event)"></mat-month-view>` ,
468
+ (selectedChange)="selectedChangeSpy($event)"
469
+ (_userSelection)="userSelectionSpy($event)"></mat-month-view>` ,
453
470
} )
454
471
class StandardMonthView {
455
472
date = new Date ( 2017 , JAN , 5 ) ;
456
473
selected : Date | DateRange < Date > = new Date ( 2017 , JAN , 10 ) ;
457
474
selectedChangeSpy = jasmine . createSpy ( 'selectedChange' ) ;
475
+ userSelectionSpy = jasmine . createSpy ( 'userSelection' ) ;
458
476
}
459
477
460
478
0 commit comments