@@ -49,9 +49,10 @@ describe('IgxDateRangePicker', () => {
4949 let overlay : IgxOverlayService ;
5050 let mockInjector ;
5151 let ngModuleRef : any ;
52+ let mockCalendar : IgxCalendarComponent ;
53+ let mockDaysView : any ;
5254 const elementRef = { nativeElement : null } ;
5355 const platform = { } as any ;
54- const calendar = new IgxCalendarComponent ( platform ) ;
5556 const mockNgControl = jasmine . createSpyObj ( 'NgControl' ,
5657 [ 'registerOnChangeCb' ,
5758 'registerOnTouchedCb' ,
@@ -134,6 +135,11 @@ describe('IgxDateRangePicker', () => {
134135
135136 overlay = new IgxOverlayService (
136137 mockFactoryResolver , mockApplicationRef , mockInjector , mockAnimationBuilder , mockDocument , mockNgZone , mockPlatformUtil ) ;
138+ mockCalendar = new IgxCalendarComponent ( platform ) ;
139+ mockDaysView = {
140+ focusActiveDate : jasmine . createSpy ( )
141+ } as any ;
142+ mockCalendar . daysView = mockDaysView ;
137143 } ) ;
138144 /* eslint-enable @typescript-eslint/no-unused-vars */
139145 it ( 'should set range dates correctly through selectRange method' , ( ) => {
@@ -240,11 +246,11 @@ describe('IgxDateRangePicker', () => {
240246 expect ( dateRange . validate ( mockFormControl ) ) . toEqual ( { minValue : true , maxValue : true } ) ;
241247 } ) ;
242248
243- it ( 'should disable calendar dates when min and/or max values as dates are provided' , fakeAsync ( ( ) => {
249+ it ( 'should disable calendar dates when min and/or max values as dates are provided' , ( ) => {
244250 const dateRange = new IgxDateRangePickerComponent ( elementRef , 'en-US' , platform , mockInjector , ngModuleRef , overlay ) ;
245251 dateRange . ngOnInit ( ) ;
246252
247- spyOnProperty ( ( dateRange as any ) , 'calendar' ) . and . returnValue ( calendar ) ;
253+ spyOnProperty ( ( dateRange as any ) , 'calendar' ) . and . returnValue ( mockCalendar ) ;
248254 dateRange . minValue = new Date ( 2000 , 10 , 1 ) ;
249255 dateRange . maxValue = new Date ( 2000 , 10 , 20 ) ;
250256
@@ -257,20 +263,20 @@ describe('IgxDateRangePicker', () => {
257263 closeAnimation : null
258264 } )
259265 } ) ;
260- tick ( ) ;
261266 ( dateRange as any ) . updateCalendar ( ) ;
262- expect ( ( dateRange as any ) . calendar . disabledDates . length ) . toEqual ( 2 ) ;
263- expect ( ( dateRange as any ) . calendar . disabledDates [ 0 ] . type ) . toEqual ( DateRangeType . Before ) ;
264- expect ( ( dateRange as any ) . calendar . disabledDates [ 0 ] . dateRange [ 0 ] ) . toEqual ( dateRange . minValue ) ;
265- expect ( ( dateRange as any ) . calendar . disabledDates [ 1 ] . type ) . toEqual ( DateRangeType . After ) ;
266- expect ( ( dateRange as any ) . calendar . disabledDates [ 1 ] . dateRange [ 0 ] ) . toEqual ( dateRange . maxValue ) ;
267- } ) ) ;
267+ expect ( mockCalendar . disabledDates . length ) . toEqual ( 2 ) ;
268+ expect ( mockCalendar . disabledDates [ 0 ] . type ) . toEqual ( DateRangeType . Before ) ;
269+ expect ( mockCalendar . disabledDates [ 0 ] . dateRange [ 0 ] ) . toEqual ( dateRange . minValue ) ;
270+ expect ( mockCalendar . disabledDates [ 1 ] . type ) . toEqual ( DateRangeType . After ) ;
271+ expect ( mockCalendar . disabledDates [ 1 ] . dateRange [ 0 ] ) . toEqual ( dateRange . maxValue ) ;
272+ expect ( mockCalendar . daysView . focusActiveDate ) . toHaveBeenCalledTimes ( 1 ) ;
273+ } ) ;
268274
269275 it ( 'should disable calendar dates when min and/or max values as strings are provided' , fakeAsync ( ( ) => {
270276 const dateRange = new IgxDateRangePickerComponent ( elementRef , null , platform , mockInjector , null , null ) ;
271277 dateRange . ngOnInit ( ) ;
272278
273- spyOnProperty ( ( dateRange as any ) , 'calendar' ) . and . returnValue ( calendar ) ;
279+ spyOnProperty ( ( dateRange as any ) , 'calendar' ) . and . returnValue ( mockCalendar ) ;
274280 dateRange . minValue = '2000/10/1' ;
275281 dateRange . maxValue = '2000/10/30' ;
276282
0 commit comments