@@ -172,7 +172,8 @@ describe('IgxCalendar - ', () => {
172172 configureTestSuite ( ) ;
173173 beforeAll ( async ( ( ) => {
174174 TestBed . configureTestingModule ( {
175- declarations : [ IgxCalendarSampleComponent , IgxCalendarRangeComponent , IgxCalendarDisabledSpecialDatesComponent ] ,
175+ declarations : [ IgxCalendarSampleComponent , IgxCalendarRangeComponent , IgxCalendarDisabledSpecialDatesComponent ,
176+ IgxCalendarValueComponent ] ,
176177 imports : [ IgxCalendarModule , FormsModule , NoopAnimationsModule ]
177178 } ) . compileComponents ( ) ;
178179 } ) ) ;
@@ -290,18 +291,23 @@ describe('IgxCalendar - ', () => {
290291 } ) ;
291292
292293 it ( 'Should show right month when value is set' , ( ) => {
294+ fixture = TestBed . createComponent ( IgxCalendarValueComponent ) ;
295+ fixture . detectChanges ( ) ;
296+ calendar = fixture . componentInstance . calendar ;
297+
293298 expect ( calendar . weekStart ) . toEqual ( WEEKDAYS . SUNDAY ) ;
294299 expect ( calendar . selection ) . toEqual ( 'single' ) ;
300+ expect ( calendar . viewDate . getMonth ( ) ) . toEqual ( calendar . value . getMonth ( ) ) ;
295301
296302 const date = new Date ( 2020 , 8 , 28 ) ;
297- calendar . value = date ;
303+ calendar . viewDate = date ;
298304 fixture . detectChanges ( ) ;
299- expect (
300- ( fixture . componentInstance . model as Date ) . toDateString ( )
301- ) . toMatch ( date . toDateString ( ) ) ;
302- expect ( ( calendar . value as Date ) . toDateString ( ) ) . toMatch (
303- date . toDateString ( )
304- ) ;
305+
306+ expect ( calendar . viewDate . getMonth ( ) ) . toEqual ( date . getMonth ( ) ) ;
307+
308+ calendar . value = new Date ( 2020 , 9 , 15 ) ;
309+ fixture . detectChanges ( ) ;
310+
305311 expect ( calendar . viewDate . getMonth ( ) ) . toEqual ( date . getMonth ( ) ) ;
306312 } ) ;
307313
@@ -1948,6 +1954,16 @@ export class IgxCalendarDisabledSpecialDatesComponent {
19481954 @ViewChild ( IgxCalendarComponent , { static : true } ) public calendar : IgxCalendarComponent ;
19491955}
19501956
1957+ @Component ( {
1958+ template : `
1959+ <igx-calendar [value]="value"></igx-calendar>
1960+ `
1961+ } )
1962+ export class IgxCalendarValueComponent {
1963+ public value = new Date ( 2020 , 7 , 13 ) ;
1964+ @ViewChild ( IgxCalendarComponent , { static : true } ) public calendar : IgxCalendarComponent ;
1965+ }
1966+
19511967class DateTester {
19521968 // tests whether a date is disabled or not
19531969 static testDatesAvailability ( dates : IgxDayItemComponent [ ] , disabled : boolean ) {
0 commit comments