@@ -2037,6 +2037,47 @@ describe('MatDatepicker', () => {
20372037 subscription . unsubscribe ( ) ;
20382038 } ) ;
20392039
2040+ describe ( 'panelClass input' , ( ) => {
2041+ let fixture : ComponentFixture < PanelClassDatepicker > ;
2042+ let testComponent : PanelClassDatepicker ;
2043+
2044+ beforeEach ( fakeAsync ( ( ) => {
2045+ fixture = createComponent ( PanelClassDatepicker , [ MatNativeDateModule ] ) ;
2046+ fixture . detectChanges ( ) ;
2047+
2048+ testComponent = fixture . componentInstance ;
2049+ } ) ) ;
2050+
2051+ afterEach ( fakeAsync ( ( ) => {
2052+ testComponent . datepicker . close ( ) ;
2053+ fixture . detectChanges ( ) ;
2054+ flush ( ) ;
2055+ } ) ) ;
2056+
2057+ it ( 'should accept a single class' , ( ) => {
2058+ testComponent . panelClass = 'foobar' ;
2059+ fixture . detectChanges ( ) ;
2060+ expect ( testComponent . datepicker . panelClass ) . toEqual ( [ 'foobar' ] ) ;
2061+ } ) ;
2062+
2063+ it ( 'should accept multiple classes' , ( ) => {
2064+ testComponent . panelClass = 'foo bar' ;
2065+ fixture . detectChanges ( ) ;
2066+ expect ( testComponent . datepicker . panelClass ) . toEqual ( [ 'foo' , 'bar' ] ) ;
2067+ } ) ;
2068+
2069+ it ( 'should work with ngClass' , ( ) => {
2070+ testComponent . panelClass = [ 'foo' , 'bar' ] ;
2071+ testComponent . datepicker . open ( ) ;
2072+ fixture . detectChanges ( ) ;
2073+
2074+ const datepickerContent = testComponent . datepicker [ '_dialogRef' ] ! ! . componentInstance ;
2075+ const actualClasses = datepickerContent . _elementRef . nativeElement . children [ 1 ] . classList ;
2076+ expect ( actualClasses . contains ( 'foo' ) ) . toBe ( true ) ;
2077+ expect ( actualClasses . contains ( 'bar' ) ) . toBe ( true ) ;
2078+ } ) ;
2079+ } ) ;
2080+
20402081} ) ;
20412082
20422083/**
@@ -2400,3 +2441,16 @@ class DatepickerInputWithCustomValidator {
24002441 min : Date ;
24012442 max : Date ;
24022443}
2444+
2445+
2446+ @Component ( {
2447+ template : `
2448+ <input [matDatepicker]="d" [value]="date">
2449+ <mat-datepicker [panelClass]="panelClass" touchUi #d></mat-datepicker>
2450+ ` ,
2451+ } )
2452+ class PanelClassDatepicker {
2453+ date = new Date ( 0 ) ;
2454+ panelClass : any ;
2455+ @ViewChild ( 'd' ) datepicker : MatDatepicker < Date > ;
2456+ }
0 commit comments