@@ -103,6 +103,59 @@ describe('IgxDatePicker', () => {
103
103
expect ( datePicker [ '_calendar' ] . orientation ) . toEqual ( PickerCalendarOrientation . Vertical . toString ( ) ) ;
104
104
expect ( datePicker [ '_calendar' ] . wrapper . nativeElement ) . toHaveClass ( CSS_CLASS_CALENDAR_WRAPPER_VERTICAL ) ;
105
105
} ) ) ;
106
+
107
+ it ( 'should initialize activeDate with current date, when not set' , fakeAsync ( ( ) => {
108
+ const datePicker = fixture . componentInstance . datePicker ;
109
+ datePicker . value = null ;
110
+ fixture . detectChanges ( ) ;
111
+ const todayDate = new Date ( ) ;
112
+ const today = new Date ( todayDate . setHours ( 0 , 0 , 0 , 0 ) ) . getTime ( ) . toString ( ) ;
113
+
114
+ expect ( datePicker . activeDate ) . toEqual ( todayDate ) ;
115
+
116
+ datePicker . open ( ) ;
117
+ fixture . detectChanges ( ) ;
118
+
119
+ expect ( datePicker [ '_calendar' ] . activeDate ) . toEqual ( todayDate ) ;
120
+ expect ( datePicker [ '_calendar' ] . value ) . toBeUndefined ( ) ;
121
+ const wrapper = fixture . debugElement . query ( By . css ( '.igx-calendar__wrapper' ) ) . nativeElement ;
122
+ expect ( wrapper . getAttribute ( 'aria-activedescendant' ) ) . toEqual ( today ) ;
123
+ } ) ) ;
124
+
125
+ it ( 'should initialize activeDate = value when it is not set, but value is' , fakeAsync ( ( ) => {
126
+ const datePicker = fixture . componentInstance . datePicker ;
127
+ const date = fixture . componentInstance . date ;
128
+
129
+ expect ( datePicker . activeDate ) . toEqual ( date ) ;
130
+ datePicker . open ( ) ;
131
+ fixture . detectChanges ( ) ;
132
+
133
+ const activeDescendantDate = new Date ( date . setHours ( 0 , 0 , 0 , 0 ) ) . getTime ( ) . toString ( ) ;
134
+ expect ( datePicker [ '_calendar' ] . activeDate ) . toEqual ( date ) ;
135
+ expect ( datePicker [ '_calendar' ] . value ) . toEqual ( date ) ;
136
+ const wrapper = fixture . debugElement . query ( By . css ( '.igx-calendar__wrapper' ) ) . nativeElement ;
137
+ expect ( wrapper . getAttribute ( 'aria-activedescendant' ) ) . toEqual ( activeDescendantDate ) ;
138
+ } ) ) ;
139
+
140
+ it ( 'should set activeDate correctly' , fakeAsync ( ( ) => {
141
+ const datePicker = fixture . componentInstance . datePicker ;
142
+ const targetDate = new Date ( 2025 , 0 , 1 ) ;
143
+ datePicker . activeDate = new Date ( targetDate ) ;
144
+ fixture . detectChanges ( ) ;
145
+
146
+ expect ( datePicker . activeDate ) . toEqual ( targetDate ) ;
147
+ expect ( datePicker . value ) . toEqual ( fixture . componentInstance . date ) ;
148
+
149
+ datePicker . open ( ) ;
150
+ fixture . detectChanges ( ) ;
151
+
152
+ const activeDescendantDate = new Date ( targetDate . setHours ( 0 , 0 , 0 , 0 ) ) . getTime ( ) . toString ( ) ;
153
+ expect ( datePicker [ '_calendar' ] . activeDate ) . toEqual ( targetDate ) ;
154
+ expect ( datePicker [ '_calendar' ] . viewDate . getMonth ( ) ) . toEqual ( targetDate . getMonth ( ) ) ;
155
+ expect ( datePicker [ '_calendar' ] . value ) . toEqual ( fixture . componentInstance . date ) ;
156
+ const wrapper = fixture . debugElement . query ( By . css ( '.igx-calendar__wrapper' ) ) . nativeElement ;
157
+ expect ( wrapper . getAttribute ( 'aria-activedescendant' ) ) . toEqual ( activeDescendantDate ) ;
158
+ } ) ) ;
106
159
} ) ;
107
160
108
161
describe ( 'Events' , ( ) => {
0 commit comments