@@ -28,6 +28,7 @@ import { NzFormModule } from '../form';
2828import en_US from '../i18n/languages/en_US' ;
2929import { NzDatePickerComponent } from './date-picker.component' ;
3030import { NzDatePickerModule } from './date-picker.module' ;
31+ import { NzPanelChangeType } from './standard-types' ;
3132import { ENTER_EVENT , getPickerAbstract , getPickerInput } from './testing/util' ;
3233import { PREFIX_CLASS } from './util' ;
3334
@@ -1129,6 +1130,7 @@ describe('NzDatePickerComponent', () => {
11291130 } ) ) ;
11301131
11311132 it ( 'should support nzOnPanelChange' , fakeAsync ( ( ) => {
1133+ fixtureInstance . nzValue = new Date ( '2020-12-01' ) ;
11321134 spyOn ( fixtureInstance , 'nzOnPanelChange' ) ;
11331135 fixture . detectChanges ( ) ;
11341136 openPickerByClickTrigger ( ) ;
@@ -1138,7 +1140,58 @@ describe('NzDatePickerComponent', () => {
11381140 fixture . detectChanges ( ) ;
11391141 tick ( 500 ) ;
11401142 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+ } ) ;
11421195 } ) ) ;
11431196
11441197 it ( 'should support nzOnOk' , fakeAsync ( ( ) => {
@@ -1487,7 +1540,9 @@ class NzTestDatePickerComponent {
14871540 nzSize ! : string ;
14881541
14891542 nzOnChange ( _ : Date | null ) : void { }
1543+
14901544 nzOnCalendarChange ( ) : void { }
1545+
14911546 nzOnOpenChange ( _ : boolean ) : void { }
14921547
14931548 nzValue : Date | null = null ;
@@ -1507,7 +1562,7 @@ class NzTestDatePickerComponent {
15071562 nzShowWeekNumber = false ;
15081563
15091564 // nzRanges;
1510- nzOnPanelChange ( _ : string ) : void { }
1565+ nzOnPanelChange ( _ : NzPanelChangeType ) : void { }
15111566
15121567 nzOnOk ( _ : Date ) : void { }
15131568
@@ -1547,5 +1602,6 @@ class NzTestDatePickerInFormComponent {
15471602 validateForm = this . fb . group ( {
15481603 demo : this . fb . control < Date | null > ( null , Validators . required )
15491604 } ) ;
1605+
15501606 constructor ( private fb : FormBuilder ) { }
15511607}
0 commit comments