@@ -174,7 +174,8 @@ describe('IgxCalendar - ', () => {
174
174
configureTestSuite ( ) ;
175
175
beforeAll ( async ( ( ) => {
176
176
TestBed . configureTestingModule ( {
177
- declarations : [ IgxCalendarSampleComponent , IgxCalendarRangeComponent , IgxCalendarDisabledSpecialDatesComponent ] ,
177
+ declarations : [ IgxCalendarSampleComponent , IgxCalendarRangeComponent , IgxCalendarDisabledSpecialDatesComponent ,
178
+ IgxCalendarValueComponent ] ,
178
179
imports : [ IgxCalendarModule , FormsModule , NoopAnimationsModule ]
179
180
} ) . compileComponents ( ) ;
180
181
} ) ) ;
@@ -291,6 +292,27 @@ describe('IgxCalendar - ', () => {
291
292
expect ( bodyMonth . nativeElement . textContent . trim ( ) ) . toMatch ( '8' ) ;
292
293
} ) ;
293
294
295
+ it ( 'Should show right month when value is set' , ( ) => {
296
+ fixture = TestBed . createComponent ( IgxCalendarValueComponent ) ;
297
+ fixture . detectChanges ( ) ;
298
+ calendar = fixture . componentInstance . calendar ;
299
+
300
+ expect ( calendar . weekStart ) . toEqual ( WEEKDAYS . SUNDAY ) ;
301
+ expect ( calendar . selection ) . toEqual ( 'single' ) ;
302
+ expect ( calendar . viewDate . getMonth ( ) ) . toEqual ( calendar . value . getMonth ( ) ) ;
303
+
304
+ const date = new Date ( 2020 , 8 , 28 ) ;
305
+ calendar . viewDate = date ;
306
+ fixture . detectChanges ( ) ;
307
+
308
+ expect ( calendar . viewDate . getMonth ( ) ) . toEqual ( date . getMonth ( ) ) ;
309
+
310
+ calendar . value = new Date ( 2020 , 9 , 15 ) ;
311
+ fixture . detectChanges ( ) ;
312
+
313
+ expect ( calendar . viewDate . getMonth ( ) ) . toEqual ( date . getMonth ( ) ) ;
314
+ } ) ;
315
+
294
316
it ( 'Should properly set locale' , ( ) => {
295
317
fixture . componentInstance . viewDate = new Date ( 2018 , 8 , 17 ) ;
296
318
fixture . componentInstance . model = new Date ( ) ;
@@ -1998,6 +2020,16 @@ export class IgxCalendarDisabledSpecialDatesComponent {
1998
2020
@ViewChild ( IgxCalendarComponent , { static : true } ) public calendar : IgxCalendarComponent ;
1999
2021
}
2000
2022
2023
+ @Component ( {
2024
+ template : `
2025
+ <igx-calendar [value]="value"></igx-calendar>
2026
+ `
2027
+ } )
2028
+ export class IgxCalendarValueComponent {
2029
+ public value = new Date ( 2020 , 7 , 13 ) ;
2030
+ @ViewChild ( IgxCalendarComponent , { static : true } ) public calendar : IgxCalendarComponent ;
2031
+ }
2032
+
2001
2033
class DateTester {
2002
2034
// tests whether a date is disabled or not
2003
2035
static testDatesAvailability ( dates : IgxDayItemComponent [ ] , disabled : boolean ) {
0 commit comments