@@ -34,14 +34,15 @@ describe('MdDatepicker', () => {
3434 let adapter = new NativeDateAdapter ( ) ;
3535 adapter . setLocale ( 'en-US' ) ;
3636 return adapter ;
37- } }
37+ } } ,
3838 ] ,
3939 declarations : [
4040 DatepickerWithFilterAndValidation ,
4141 DatepickerWithFormControl ,
4242 DatepickerWithMinAndMaxValidation ,
4343 DatepickerWithNgModel ,
4444 DatepickerWithStartAt ,
45+ DatepickerWithStartView ,
4546 DatepickerWithToggle ,
4647 InputContainerDatepicker ,
4748 MultiInputDatepicker ,
@@ -203,6 +204,35 @@ describe('MdDatepicker', () => {
203204 } ) ;
204205 } ) ;
205206
207+ describe ( 'datepicker with startView' , ( ) => {
208+ let fixture : ComponentFixture < DatepickerWithStartView > ;
209+ let testComponent : DatepickerWithStartView ;
210+
211+ beforeEach ( async ( ( ) => {
212+ fixture = TestBed . createComponent ( DatepickerWithStartView ) ;
213+ fixture . detectChanges ( ) ;
214+
215+ testComponent = fixture . componentInstance ;
216+ } ) ) ;
217+
218+ afterEach ( async ( ( ) => {
219+ testComponent . datepicker . close ( ) ;
220+ fixture . detectChanges ( ) ;
221+ } ) ) ;
222+
223+ it ( 'should start at the specified view' , ( ) => {
224+ testComponent . datepicker . open ( ) ;
225+ fixture . detectChanges ( ) ;
226+
227+ const firstCalendarCell = document . querySelector ( '.mat-calendar-body-cell' ) ;
228+
229+ // When the calendar is in year view, the first cell should be for a month rather than
230+ // for a date.
231+ expect ( firstCalendarCell . textContent )
232+ . toBe ( 'JAN' , 'Expected the calendar to be in year-view' ) ;
233+ } ) ;
234+ } ) ;
235+
206236 describe ( 'datepicker with ngModel' , ( ) => {
207237 let fixture : ComponentFixture < DatepickerWithNgModel > ;
208238 let testComponent : DatepickerWithNgModel ;
@@ -698,6 +728,18 @@ class DatepickerWithStartAt {
698728}
699729
700730
731+ @Component ( {
732+ template : `
733+ <input [mdDatepicker]="d" [value]="date">
734+ <md-datepicker #d startView="year"></md-datepicker>
735+ ` ,
736+ } )
737+ class DatepickerWithStartView {
738+ date = new Date ( 2020 , JAN , 1 ) ;
739+ @ViewChild ( 'd' ) datepicker : MdDatepicker < Date > ;
740+ }
741+
742+
701743@Component ( {
702744 template : `<input [(ngModel)]="selected" [mdDatepicker]="d"><md-datepicker #d></md-datepicker>` ,
703745} )
0 commit comments