@@ -28,6 +28,7 @@ import { NzFormModule } from '../form';
28
28
import en_US from '../i18n/languages/en_US' ;
29
29
import { NzDatePickerComponent } from './date-picker.component' ;
30
30
import { NzDatePickerModule } from './date-picker.module' ;
31
+ import { NzPanelChangeType } from './standard-types' ;
31
32
import { ENTER_EVENT , getPickerAbstract , getPickerInput } from './testing/util' ;
32
33
import { PREFIX_CLASS } from './util' ;
33
34
@@ -1129,6 +1130,7 @@ describe('NzDatePickerComponent', () => {
1129
1130
} ) ) ;
1130
1131
1131
1132
it ( 'should support nzOnPanelChange' , fakeAsync ( ( ) => {
1133
+ fixtureInstance . nzValue = new Date ( '2020-12-01' ) ;
1132
1134
spyOn ( fixtureInstance , 'nzOnPanelChange' ) ;
1133
1135
fixture . detectChanges ( ) ;
1134
1136
openPickerByClickTrigger ( ) ;
@@ -1138,7 +1140,58 @@ describe('NzDatePickerComponent', () => {
1138
1140
fixture . detectChanges ( ) ;
1139
1141
tick ( 500 ) ;
1140
1142
fixture . detectChanges ( ) ;
1141
- expect ( fixtureInstance . nzOnPanelChange ) . toHaveBeenCalledWith ( 'month' ) ;
1143
+ expect ( fixtureInstance . nzOnPanelChange ) . toHaveBeenCalledWith ( { mode : 'month' , date : new Date ( '2020-12-01' ) } ) ;
1144
+ } ) ) ;
1145
+
1146
+ it ( 'should support nzOnPanelChange when next button is clicked' , fakeAsync ( ( ) => {
1147
+ fixtureInstance . nzValue = new Date ( '2020-11-01' ) ;
1148
+ spyOn ( fixtureInstance , 'nzOnPanelChange' ) ;
1149
+ fixture . detectChanges ( ) ;
1150
+ openPickerByClickTrigger ( ) ;
1151
+ dispatchMouseEvent ( getNextBtn ( ) , 'click' ) ;
1152
+ fixture . detectChanges ( ) ;
1153
+ tick ( 500 ) ;
1154
+ fixture . detectChanges ( ) ;
1155
+ expect ( fixtureInstance . nzOnPanelChange ) . toHaveBeenCalledWith ( { mode : 'date' , date : new Date ( '2020-12-01' ) } ) ;
1156
+ } ) ) ;
1157
+ it ( 'should support nzOnPanelChange when super next button is clicked' , fakeAsync ( ( ) => {
1158
+ fixtureInstance . nzValue = new Date ( '2020-11-01' ) ;
1159
+ spyOn ( fixtureInstance , 'nzOnPanelChange' ) ;
1160
+ fixture . detectChanges ( ) ;
1161
+ openPickerByClickTrigger ( ) ;
1162
+ dispatchMouseEvent ( getSuperNextBtn ( ) , 'click' ) ;
1163
+ fixture . detectChanges ( ) ;
1164
+ tick ( 500 ) ;
1165
+ fixture . detectChanges ( ) ;
1166
+ expect ( fixtureInstance . nzOnPanelChange ) . toHaveBeenCalledWith ( { mode : 'date' , date : new Date ( '2021-11-01' ) } ) ;
1167
+ } ) ) ;
1168
+ it ( 'should support nzOnPanelChange when previous button is clicked' , fakeAsync ( ( ) => {
1169
+ fixtureInstance . nzValue = new Date ( '2020-11-01 11:22:33' ) ;
1170
+ spyOn ( fixtureInstance , 'nzOnPanelChange' ) ;
1171
+ fixture . detectChanges ( ) ;
1172
+ openPickerByClickTrigger ( ) ;
1173
+ dispatchMouseEvent ( getPreBtn ( ) , 'click' ) ;
1174
+ fixture . detectChanges ( ) ;
1175
+ tick ( 500 ) ;
1176
+ fixture . detectChanges ( ) ;
1177
+ expect ( fixtureInstance . nzOnPanelChange ) . toHaveBeenCalledWith ( {
1178
+ mode : 'date' ,
1179
+ date : new Date ( '2020-10-01 11:22:33' )
1180
+ } ) ;
1181
+ } ) ) ;
1182
+ it ( 'should support nzOnPanelChange when super previous button is clicked' , fakeAsync ( ( ) => {
1183
+ fixtureInstance . nzValue = new Date ( '2020-11-01 11:22:33' ) ;
1184
+ spyOn ( fixtureInstance , 'nzOnPanelChange' ) ;
1185
+ fixture . detectChanges ( ) ;
1186
+ openPickerByClickTrigger ( ) ;
1187
+ dispatchMouseEvent ( getSuperPreBtn ( ) , 'click' ) ;
1188
+ fixture . detectChanges ( ) ;
1189
+ tick ( 500 ) ;
1190
+ fixture . detectChanges ( ) ;
1191
+ expect ( fixtureInstance . nzOnPanelChange ) . toHaveBeenCalledWith ( {
1192
+ mode : 'date' ,
1193
+ date : new Date ( '2019-11-01 11:22:33' )
1194
+ } ) ;
1142
1195
} ) ) ;
1143
1196
1144
1197
it ( 'should support nzOnOk' , fakeAsync ( ( ) => {
@@ -1487,7 +1540,9 @@ class NzTestDatePickerComponent {
1487
1540
nzSize ! : string ;
1488
1541
1489
1542
nzOnChange ( _ : Date | null ) : void { }
1543
+
1490
1544
nzOnCalendarChange ( ) : void { }
1545
+
1491
1546
nzOnOpenChange ( _ : boolean ) : void { }
1492
1547
1493
1548
nzValue : Date | null = null ;
@@ -1507,7 +1562,7 @@ class NzTestDatePickerComponent {
1507
1562
nzShowWeekNumber = false ;
1508
1563
1509
1564
// nzRanges;
1510
- nzOnPanelChange ( _ : string ) : void { }
1565
+ nzOnPanelChange ( _ : NzPanelChangeType ) : void { }
1511
1566
1512
1567
nzOnOk ( _ : Date ) : void { }
1513
1568
@@ -1547,5 +1602,6 @@ class NzTestDatePickerInFormComponent {
1547
1602
validateForm = this . fb . group ( {
1548
1603
demo : this . fb . control < Date | null > ( null , Validators . required )
1549
1604
} ) ;
1605
+
1550
1606
constructor ( private fb : FormBuilder ) { }
1551
1607
}
0 commit comments