@@ -519,6 +519,52 @@ describe('useDatepicker', () => {
519519 clear ( )
520520 } )
521521
522+
523+ test ( 'should check if date is start date' , ( ) => {
524+ const onDatesChange = jest . fn ( )
525+ advanceTo ( new Date ( 2019 , 2 , 27 , 0 , 0 , 0 ) )
526+ const { result} = renderHook ( ( ) =>
527+ useDatepicker ( {
528+ startDate : new Date ( 2019 , 3 , 1 , 0 , 0 , 0 ) ,
529+ endDate : new Date ( 2019 , 3 , 3 , 0 , 0 , 0 ) ,
530+ minBookingDate : new Date ( 2019 , 3 , 1 , 0 , 0 , 0 ) ,
531+ maxBookingDate : new Date ( 2019 , 3 , 10 , 0 , 0 , 0 ) ,
532+ focusedInput : START_DATE ,
533+ onDatesChange : onDatesChange ,
534+ } ) ,
535+ )
536+
537+ expect ( result . current . isStartDate ( new Date ( 2019 , 3 , 1 , 0 , 0 , 0 ) ) ) . toBe ( true )
538+ expect ( result . current . isStartDate ( new Date ( 2019 , 3 , 2 , 0 , 0 , 0 ) ) ) . toBe ( false )
539+ expect ( result . current . isStartDate ( new Date ( 2019 , 3 , 3 , 0 , 0 , 0 ) ) ) . toBe ( false )
540+ expect ( result . current . isStartDate ( new Date ( 2019 , 3 , 10 , 0 , 0 , 0 ) ) ) . toBe ( false )
541+ expect ( result . current . isStartDate ( new Date ( 2019 , 2 , 27 , 0 , 0 , 0 ) ) ) . toBe ( false )
542+ clear ( )
543+ } )
544+
545+
546+ test ( 'should check if date is end date' , ( ) => {
547+ const onDatesChange = jest . fn ( )
548+ advanceTo ( new Date ( 2019 , 3 , 27 , 0 , 0 , 0 ) )
549+ const { result} = renderHook ( ( ) =>
550+ useDatepicker ( {
551+ startDate : new Date ( 2019 , 3 , 1 , 0 , 0 , 0 ) ,
552+ endDate : new Date ( 2019 , 3 , 3 , 0 , 0 , 0 ) ,
553+ minBookingDate : new Date ( 2019 , 3 , 1 , 0 , 0 , 0 ) ,
554+ maxBookingDate : new Date ( 2019 , 3 , 10 , 0 , 0 , 0 ) ,
555+ focusedInput : START_DATE ,
556+ onDatesChange : onDatesChange ,
557+ } ) ,
558+ )
559+
560+ expect ( result . current . isEndDate ( new Date ( 2019 , 3 , 1 , 0 , 0 , 0 ) ) ) . toBe ( false )
561+ expect ( result . current . isEndDate ( new Date ( 2019 , 3 , 2 , 0 , 0 , 0 ) ) ) . toBe ( false )
562+ expect ( result . current . isEndDate ( new Date ( 2019 , 3 , 3 , 0 , 0 , 0 ) ) ) . toBe ( true )
563+ expect ( result . current . isEndDate ( new Date ( 2019 , 3 , 10 , 0 , 0 , 0 ) ) ) . toBe ( false )
564+ expect ( result . current . isEndDate ( new Date ( 2019 , 3 , 27 , 0 , 0 , 0 ) ) ) . toBe ( false )
565+ clear ( )
566+ } )
567+
522568 test . each ( [
523569 {
524570 startDate : null ,
0 commit comments