@@ -812,10 +812,6 @@ describe('Picker.Basic', () => {
812812 /> ,
813813 ) ;
814814
815- expect ( errSpy ) . toHaveBeenCalledWith (
816- "Warning: 'defaultOpenValue' is deprecated which merged into 'defaultPickerValue' instead." ,
817- ) ;
818-
819815 openPicker ( container ) ;
820816 fireEvent . click ( document . querySelector ( '.rc-picker-ok button' ) ) ;
821817
@@ -1377,17 +1373,60 @@ describe('Picker.Basic', () => {
13771373 ) . toEqual ( '01' ) ;
13781374 } ) ;
13791375
1380- it ( 'time picker should align to 0' , ( ) => {
1381- jest . useFakeTimers ( ) . setSystemTime ( getDay ( '1990-09-03 01:03:05' ) . valueOf ( ) ) ;
1376+ describe ( 'time with defaultPickerValue' , ( ) => {
1377+ beforeEach ( ( ) => {
1378+ jest . useFakeTimers ( ) . setSystemTime ( getDay ( '1990-09-03 01:03:05' ) . valueOf ( ) ) ;
1379+ } ) ;
13821380
1383- const onCalendarChange = jest . fn ( ) ;
1384- render ( < DayPicker picker = "time" open showNow onCalendarChange = { onCalendarChange } /> ) ;
1381+ it ( 'time picker should align to 0' , ( ) => {
1382+ const onCalendarChange = jest . fn ( ) ;
1383+ render ( < DayPicker picker = "time" open showNow onCalendarChange = { onCalendarChange } /> ) ;
1384+
1385+ const submitBtn = document . querySelector ( '.rc-picker-ok button' ) ;
1386+ expect ( submitBtn ) . toHaveAttribute ( 'disabled' ) ;
1387+
1388+ selectCell ( '00' ) ;
1389+ expect ( submitBtn ) . not . toHaveAttribute ( 'disabled' ) ;
1390+ expect ( onCalendarChange ) . toHaveBeenCalledWith (
1391+ expect . anything ( ) ,
1392+ '00:00:00' ,
1393+ expect . anything ( ) ,
1394+ ) ;
1395+ onCalendarChange . mockReset ( ) ;
1396+
1397+ fireEvent . click ( document . querySelector ( '.rc-picker-now-btn' ) ) ;
1398+ expect ( submitBtn ) . not . toHaveAttribute ( 'disabled' ) ;
1399+ expect ( onCalendarChange ) . toHaveBeenCalledWith (
1400+ expect . anything ( ) ,
1401+ '01:03:05' ,
1402+ expect . anything ( ) ,
1403+ ) ;
1404+ } ) ;
13851405
1386- selectCell ( '00' ) ;
1387- expect ( onCalendarChange ) . toHaveBeenCalledWith ( expect . anything ( ) , '00:00:00' , expect . anything ( ) ) ;
1388- onCalendarChange . mockReset ( ) ;
1406+ function testPropsName ( propName : string ) {
1407+ it ( `${ propName } with showTime` , ( ) => {
1408+ const onCalendarChange = jest . fn ( ) ;
1409+ render (
1410+ < DayPicker
1411+ showTime = { {
1412+ [ propName ] : dayjs ( ) ,
1413+ } }
1414+ open
1415+ onCalendarChange = { onCalendarChange }
1416+ defaultPickerValue = { dayjs ( ) }
1417+ /> ,
1418+ ) ;
1419+
1420+ selectCell ( 15 ) ;
1421+ expect ( onCalendarChange ) . toHaveBeenCalledWith (
1422+ expect . anything ( ) ,
1423+ '1990-09-15 01:03:05' ,
1424+ expect . anything ( ) ,
1425+ ) ;
1426+ } ) ;
1427+ }
13891428
1390- fireEvent . click ( document . querySelector ( '.rc-picker-now-btn' ) ) ;
1391- expect ( onCalendarChange ) . toHaveBeenCalledWith ( expect . anything ( ) , '01:03:05' , expect . anything ( ) ) ;
1429+ testPropsName ( 'defaultValue' ) ;
1430+ testPropsName ( 'defaultOpenValue' ) ;
13921431 } ) ;
13931432} ) ;
0 commit comments