@@ -104,7 +104,7 @@ describe('MatDatepicker', () => {
104
104
. not . toBeNull ( ) ;
105
105
} ) ;
106
106
107
- it ( 'should open datepicker if opened input is set to true' , async ( ( ) => {
107
+ it ( 'should open datepicker if opened input is set to true' , ( ) => {
108
108
testComponent . opened = true ;
109
109
fixture . detectChanges ( ) ;
110
110
@@ -113,10 +113,8 @@ describe('MatDatepicker', () => {
113
113
testComponent . opened = false ;
114
114
fixture . detectChanges ( ) ;
115
115
116
- fixture . whenStable ( ) . then ( ( ) => {
117
- expect ( document . querySelector ( '.mat-datepicker-content' ) ) . toBeNull ( ) ;
118
- } ) ;
119
- } ) ) ;
116
+ expect ( document . querySelector ( '.mat-datepicker-content' ) ) . toBeNull ( ) ;
117
+ } ) ;
120
118
121
119
it ( 'open in disabled mode should not open the calendar' , ( ) => {
122
120
testComponent . disabled = true ;
@@ -156,9 +154,7 @@ describe('MatDatepicker', () => {
156
154
testComponent . datepicker . close ( ) ;
157
155
fixture . detectChanges ( ) ;
158
156
159
- fixture . whenStable ( ) . then ( ( ) => {
160
- expect ( parseInt ( getComputedStyle ( popup ) . height as string ) ) . toBe ( 0 ) ;
161
- } ) ;
157
+ expect ( parseInt ( getComputedStyle ( popup ) . height as string ) ) . toBe ( 0 ) ;
162
158
} ) ;
163
159
164
160
it ( 'should close the popup when pressing ESCAPE' , ( ) => {
@@ -182,7 +178,7 @@ describe('MatDatepicker', () => {
182
178
. toBe ( true , 'Expected default ESCAPE action to be prevented.' ) ;
183
179
} ) ;
184
180
185
- it ( 'close should close dialog' , ( ) => {
181
+ it ( 'close should close dialog' , async ( ( ) => {
186
182
testComponent . touch = true ;
187
183
fixture . detectChanges ( ) ;
188
184
@@ -197,9 +193,9 @@ describe('MatDatepicker', () => {
197
193
fixture . whenStable ( ) . then ( ( ) => {
198
194
expect ( document . querySelector ( 'mat-dialog-container' ) ) . toBeNull ( ) ;
199
195
} ) ;
200
- } ) ;
196
+ } ) ) ;
201
197
202
- it ( 'setting selected should update input and close calendar' , ( ) => {
198
+ it ( 'setting selected should update input and close calendar' , async ( ( ) => {
203
199
testComponent . touch = true ;
204
200
fixture . detectChanges ( ) ;
205
201
@@ -217,12 +213,13 @@ describe('MatDatepicker', () => {
217
213
expect ( document . querySelector ( 'mat-dialog-container' ) ) . toBeNull ( ) ;
218
214
expect ( testComponent . datepickerInput . value ) . toEqual ( new Date ( 2020 , JAN , 2 ) ) ;
219
215
} ) ;
220
- } ) ;
216
+ } ) ) ;
221
217
222
218
it ( 'clicking the currently selected date should close the calendar ' +
223
219
'without firing selectedChanged' , ( ) => {
224
220
const selectedChangedSpy =
225
221
spyOn ( testComponent . datepicker . selectedChanged , 'emit' ) . and . callThrough ( ) ;
222
+
226
223
for ( let changeCount = 1 ; changeCount < 3 ; changeCount ++ ) {
227
224
const currentDay = changeCount ;
228
225
testComponent . datepicker . open ( ) ;
@@ -236,11 +233,9 @@ describe('MatDatepicker', () => {
236
233
fixture . detectChanges ( ) ;
237
234
}
238
235
239
- fixture . whenStable ( ) . then ( ( ) => {
240
- expect ( selectedChangedSpy . calls . count ( ) ) . toEqual ( 1 ) ;
241
- expect ( document . querySelector ( 'mat-dialog-container' ) ) . toBeNull ( ) ;
242
- expect ( testComponent . datepickerInput . value ) . toEqual ( new Date ( 2020 , JAN , 2 ) ) ;
243
- } ) ;
236
+ expect ( selectedChangedSpy . calls . count ( ) ) . toEqual ( 1 ) ;
237
+ expect ( document . querySelector ( 'mat-dialog-container' ) ) . toBeNull ( ) ;
238
+ expect ( testComponent . datepickerInput . value ) . toEqual ( new Date ( 2020 , JAN , 2 ) ) ;
244
239
} ) ;
245
240
246
241
it ( 'startAt should fallback to input value' , ( ) => {
@@ -488,7 +483,7 @@ describe('MatDatepicker', () => {
488
483
expect ( inputEl . classList ) . toContain ( 'ng-touched' ) ;
489
484
} ) ;
490
485
491
- it ( 'should mark input touched on calendar selection' , ( ) => {
486
+ it ( 'should mark input touched on calendar selection' , async ( ( ) => {
492
487
let inputEl = fixture . debugElement . query ( By . css ( 'input' ) ) . nativeElement ;
493
488
494
489
expect ( inputEl . classList ) . toContain ( 'ng-untouched' ) ;
@@ -501,7 +496,7 @@ describe('MatDatepicker', () => {
501
496
502
497
expect ( inputEl . classList ) . toContain ( 'ng-touched' ) ;
503
498
} ) ;
504
- } ) ;
499
+ } ) ) ;
505
500
} ) ;
506
501
507
502
describe ( 'datepicker with formControl' , ( ) => {
@@ -711,7 +706,7 @@ describe('MatDatepicker', () => {
711
706
expect ( testComponent . datepicker . _maxDate ) . toEqual ( new Date ( 2020 , JAN , 1 ) ) ;
712
707
} ) ;
713
708
714
- it ( 'should mark invalid when value is before min' , ( ) => {
709
+ it ( 'should mark invalid when value is before min' , async ( ( ) => {
715
710
testComponent . date = new Date ( 2009 , DEC , 31 ) ;
716
711
fixture . detectChanges ( ) ;
717
712
@@ -721,9 +716,9 @@ describe('MatDatepicker', () => {
721
716
expect ( fixture . debugElement . query ( By . css ( 'input' ) ) . nativeElement . classList )
722
717
. toContain ( 'ng-invalid' ) ;
723
718
} ) ;
724
- } ) ;
719
+ } ) ) ;
725
720
726
- it ( 'should mark invalid when value is after max' , ( ) => {
721
+ it ( 'should mark invalid when value is after max' , async ( ( ) => {
727
722
testComponent . date = new Date ( 2020 , JAN , 2 ) ;
728
723
fixture . detectChanges ( ) ;
729
724
@@ -733,9 +728,9 @@ describe('MatDatepicker', () => {
733
728
expect ( fixture . debugElement . query ( By . css ( 'input' ) ) . nativeElement . classList )
734
729
. toContain ( 'ng-invalid' ) ;
735
730
} ) ;
736
- } ) ;
731
+ } ) ) ;
737
732
738
- it ( 'should not mark invalid when value equals min' , ( ) => {
733
+ it ( 'should not mark invalid when value equals min' , async ( ( ) => {
739
734
testComponent . date = testComponent . datepicker . _minDate ;
740
735
fixture . detectChanges ( ) ;
741
736
@@ -745,9 +740,9 @@ describe('MatDatepicker', () => {
745
740
expect ( fixture . debugElement . query ( By . css ( 'input' ) ) . nativeElement . classList )
746
741
. not . toContain ( 'ng-invalid' ) ;
747
742
} ) ;
748
- } ) ;
743
+ } ) ) ;
749
744
750
- it ( 'should not mark invalid when value equals max' , ( ) => {
745
+ it ( 'should not mark invalid when value equals max' , async ( ( ) => {
751
746
testComponent . date = testComponent . datepicker . _maxDate ;
752
747
fixture . detectChanges ( ) ;
753
748
@@ -757,9 +752,9 @@ describe('MatDatepicker', () => {
757
752
expect ( fixture . debugElement . query ( By . css ( 'input' ) ) . nativeElement . classList )
758
753
. not . toContain ( 'ng-invalid' ) ;
759
754
} ) ;
760
- } ) ;
755
+ } ) ) ;
761
756
762
- it ( 'should not mark invalid when value is between min and max' , ( ) => {
757
+ it ( 'should not mark invalid when value is between min and max' , async ( ( ) => {
763
758
testComponent . date = new Date ( 2010 , JAN , 2 ) ;
764
759
fixture . detectChanges ( ) ;
765
760
@@ -769,7 +764,7 @@ describe('MatDatepicker', () => {
769
764
expect ( fixture . debugElement . query ( By . css ( 'input' ) ) . nativeElement . classList )
770
765
. not . toContain ( 'ng-invalid' ) ;
771
766
} ) ;
772
- } ) ;
767
+ } ) ) ;
773
768
} ) ;
774
769
775
770
describe ( 'datepicker with filter and validation' , ( ) => {
@@ -1057,17 +1052,17 @@ describe('MatDatepicker', () => {
1057
1052
input = fixture . nativeElement . querySelector ( 'input' ) as HTMLInputElement ;
1058
1053
} ) ) ;
1059
1054
1060
- it ( 'should have the correct input value even when inverted date format' , ( ) => {
1055
+ it ( 'should have the correct input value even when inverted date format' , async ( ( ) => {
1061
1056
let selected = new Date ( 2017 , SEP , 1 ) ;
1062
1057
testComponent . date = selected ;
1063
1058
fixture . detectChanges ( ) ;
1064
1059
1065
1060
fixture . whenStable ( ) . then ( ( ) => {
1066
1061
fixture . detectChanges ( ) ;
1067
- expect ( input . value ) . toBe ( '01.09 .2017' ) ;
1062
+ expect ( input . value ) . toBe ( '1.9 .2017' ) ;
1068
1063
expect ( testComponent . datepickerInput . value ) . toBe ( selected ) ;
1069
1064
} ) ;
1070
- } ) ;
1065
+ } ) ) ;
1071
1066
} ) ;
1072
1067
} ) ;
1073
1068
0 commit comments