@@ -5,6 +5,7 @@ import sinon from 'sinon-sandbox';
55import { mount , shallow } from 'enzyme' ;
66
77import * as isDayVisible from '../../src/utils/isDayVisible' ;
8+ import isSameMonth from '../../src/utils/isSameMonth' ;
89
910import DayPicker , { PureDayPicker } from '../../src/components/DayPicker' ;
1011import CalendarMonthGrid from '../../src/components/CalendarMonthGrid' ;
@@ -221,17 +222,21 @@ describe('DayPicker', () => {
221222 < DayPicker orientation = { VERTICAL_SCROLLABLE } /> ,
222223 { disableLifecycleMethods : false } ,
223224 ) . dive ( ) ;
224- const nav = wrapper . find ( DayPickerNavigation ) [ 1 ] ;
225- expect ( nav . prop ( 'onNextMonthClick' ) ) . to . equal ( wrapper . instance ( ) . getNextScrollableMonths ) ;
225+ expect ( wrapper . find ( DayPickerNavigation ) ) . to . have . length ( 2 ) ;
226+ const nav = wrapper . find ( DayPickerNavigation ) . get ( 1 ) ;
227+ console . log ( nav ) ;
228+ expect ( nav . props . onNextMonthClick ) . to . equal ( wrapper . instance ( ) . getNextScrollableMonths ) ;
226229 } ) ;
227230
228231 it ( 'uses getPrevScrollableMonths instead of onNextMonthClick' , ( ) => {
229232 const wrapper = shallow (
230233 < DayPicker orientation = { VERTICAL_SCROLLABLE } /> ,
231234 { disableLifecycleMethods : false } ,
232235 ) . dive ( ) ;
233- const nav = wrapper . find ( DayPickerNavigation ) [ 0 ] ;
234- expect ( nav . prop ( 'onPrevMonthClick' ) ) . to . equal ( wrapper . instance ( ) . getPrevScrollableMonths ) ;
236+ expect ( wrapper . find ( DayPickerNavigation ) ) . to . have . length ( 2 ) ;
237+ const nav = wrapper . find ( DayPickerNavigation ) . get ( 0 ) ;
238+ console . log ( nav ) ;
239+ expect ( nav . props . onPrevMonthClick ) . to . equal ( wrapper . instance ( ) . getPrevScrollableMonths ) ;
235240 } ) ;
236241 } ) ;
237242
@@ -818,26 +823,14 @@ describe('DayPicker', () => {
818823 wrapper . instance ( ) . getNextScrollableMonths ( event ) ;
819824 expect ( wrapper . state ( ) . scrollableMonthMultiple ) . to . equal ( 2 ) ;
820825 } ) ;
821-
822- it ( 'increments scrollableMonthMultiple without an event' , ( ) => {
823- const wrapper = shallow ( < DayPicker /> ) . dive ( ) ;
824- wrapper . instance ( ) . getNextScrollableMonths ( ) ;
825- expect ( wrapper . state ( ) . scrollableMonthMultiple ) . to . equal ( 2 ) ;
826- } ) ;
827826 } ) ;
828827
829828 describe ( '#getPrevScrollableMonths' , ( ) => {
830- it ( 'increments scrollableMonthMultiple' , ( ) => {
831- const wrapper = shallow ( < DayPicker /> ) . dive ( ) ;
832- wrapper . instance ( ) . getPrevScrollableMonths ( event ) ;
833- expect ( wrapper . state ( ) . scrollableMonthMultiple ) . to . equal ( 2 ) ;
834- } ) ;
835-
836- it ( 'increments scrollableMonthMultiple without an event' , ( ) => {
829+ it ( 'increments scrollableMonthMultiple and updates currentMonth' , ( ) => {
837830 const wrapper = shallow ( < DayPicker /> ) . dive ( ) ;
838831 wrapper . instance ( ) . getPrevScrollableMonths ( ) ;
839832 expect ( wrapper . state ( ) . scrollableMonthMultiple ) . to . equal ( 2 ) ;
840- expect ( wrapper . state ( ) . currentMonth ) . to . equal ( moment ( ) . subtract ( 1 , 'month' ) ) ;
833+ expect ( isSameMonth ( wrapper . state ( ) . currentMonth , moment ( ) . subtract ( 2 , 'month' ) ) ) . to . equal ( true ) ;
841834 } ) ;
842835 } ) ;
843836
0 commit comments