@@ -34,14 +34,15 @@ describe('MdDatepicker', () => {
34
34
let adapter = new NativeDateAdapter ( ) ;
35
35
adapter . setLocale ( 'en-US' ) ;
36
36
return adapter ;
37
- } }
37
+ } } ,
38
38
] ,
39
39
declarations : [
40
40
DatepickerWithFilterAndValidation ,
41
41
DatepickerWithFormControl ,
42
42
DatepickerWithMinAndMaxValidation ,
43
43
DatepickerWithNgModel ,
44
44
DatepickerWithStartAt ,
45
+ DatepickerWithStartView ,
45
46
DatepickerWithToggle ,
46
47
InputContainerDatepicker ,
47
48
MultiInputDatepicker ,
@@ -203,6 +204,35 @@ describe('MdDatepicker', () => {
203
204
} ) ;
204
205
} ) ;
205
206
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
+
206
236
describe ( 'datepicker with ngModel' , ( ) => {
207
237
let fixture : ComponentFixture < DatepickerWithNgModel > ;
208
238
let testComponent : DatepickerWithNgModel ;
@@ -698,6 +728,18 @@ class DatepickerWithStartAt {
698
728
}
699
729
700
730
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
+
701
743
@Component ( {
702
744
template : `<input [(ngModel)]="selected" [mdDatepicker]="d"><md-datepicker #d></md-datepicker>` ,
703
745
} )
0 commit comments