@@ -12,6 +12,7 @@ import CalendarMonthGrid from '../../src/components/CalendarMonthGrid';
1212import DayPickerNavigation from '../../src/components/DayPickerNavigation' ;
1313import DayPickerKeyboardShortcuts from '../../src/components/DayPickerKeyboardShortcuts' ;
1414import {
15+ DAY_SIZE ,
1516 HORIZONTAL_ORIENTATION ,
1617 VERTICAL_ORIENTATION ,
1718 VERTICAL_SCROLLABLE ,
@@ -22,8 +23,9 @@ const today = moment().locale('en');
2223const event = { preventDefault ( ) { } , stopPropagation ( ) { } } ;
2324
2425describe ( 'DayPicker' , ( ) => {
26+ let adjustDayPickerHeightSpy ;
2527 beforeEach ( ( ) => {
26- sinon . stub ( PureDayPicker . prototype , 'adjustDayPickerHeight' ) ;
28+ adjustDayPickerHeightSpy = sinon . stub ( PureDayPicker . prototype , 'adjustDayPickerHeight' ) ;
2729 } ) ;
2830
2931 afterEach ( ( ) => {
@@ -907,13 +909,8 @@ describe('DayPicker', () => {
907909 } ) ;
908910 } ) ;
909911
910- describe . skip ( 'life cycle methods' , ( ) => {
911- let adjustDayPickerHeightSpy ;
912- beforeEach ( ( ) => {
913- adjustDayPickerHeightSpy = sinon . stub ( PureDayPicker . prototype , 'adjustDayPickerHeight' ) ;
914- } ) ;
915-
916- describe ( '#componentDidMount' , ( ) => {
912+ describe ( 'life cycle methods' , ( ) => {
913+ describe . skip ( '#componentDidMount' , ( ) => {
917914 describe ( 'props.orientation === HORIZONTAL_ORIENTATION' , ( ) => {
918915 it ( 'calls adjustDayPickerHeight' , ( ) => {
919916 mount ( < DayPicker orientation = { HORIZONTAL_ORIENTATION } /> ) ;
@@ -927,7 +924,7 @@ describe('DayPicker', () => {
927924 } ) ;
928925 } ) ;
929926
930- describe ( 'props.orientation === VERTICAL_ORIENTATION' , ( ) => {
927+ describe . skip ( 'props.orientation === VERTICAL_ORIENTATION' , ( ) => {
931928 it ( 'does not call adjustDayPickerHeight' , ( ) => {
932929 mount ( < DayPicker orientation = { VERTICAL_ORIENTATION } /> ) ;
933930 expect ( adjustDayPickerHeightSpy . called ) . to . equal ( false ) ;
@@ -949,7 +946,7 @@ describe('DayPicker', () => {
949946 } ) ;
950947 } ) ;
951948
952- describe ( '#componentWillReceiveProps' , ( ) => {
949+ describe . skip ( '#componentWillReceiveProps' , ( ) => {
953950 describe ( 'props.orientation === VERTICAL_SCROLLABLE' , ( ) => {
954951 it ( 'updates state.currentMonthScrollTop' , ( ) => {
955952 sinon . spy ( DayPicker . prototype , 'setTransitionContainerRef' ) ;
@@ -966,39 +963,40 @@ describe('DayPicker', () => {
966963
967964 describe ( '#componentDidUpdate' , ( ) => {
968965 let updateStateAfterMonthTransitionSpy ;
966+
969967 beforeEach ( ( ) => {
970968 updateStateAfterMonthTransitionSpy = sinon . stub (
971- DayPicker . prototype ,
969+ PureDayPicker . prototype ,
972970 'updateStateAfterMonthTransition' ,
973971 ) ;
974972 } ) ;
975973
976974 describe ( 'props.orientation === HORIZONTAL_ORIENTATION' , ( ) => {
977- it ( 'calls adjustDayPickerHeight if state.monthTransition is truthy' , ( ) => {
975+ it . skip ( 'calls adjustDayPickerHeight if state.monthTransition is truthy' , ( ) => {
978976 const wrapper = mount ( < DayPicker orientation = { HORIZONTAL_ORIENTATION } /> ) ;
979977 wrapper . setState ( {
980978 monthTransition : 'foo' ,
981979 } ) ;
982980 expect ( adjustDayPickerHeightSpy ) . to . have . property ( 'callCount' , 2 ) ;
983981 } ) ;
984982
985- it ( 'does not call adjustDayPickerHeight if state.monthTransition is falsy' , ( ) => {
983+ it . skip ( 'does not call adjustDayPickerHeight if state.monthTransition is falsy' , ( ) => {
986984 const wrapper = mount ( < DayPicker orientation = { HORIZONTAL_ORIENTATION } /> ) ;
987985 wrapper . setState ( {
988986 monthTransition : null ,
989987 } ) ;
990988 expect ( adjustDayPickerHeightSpy . calledTwice ) . to . equal ( false ) ;
991989 } ) ;
992990
993- it ( 'calls adjustDayPickerHeight if orientation has changed from HORIZONTAL_ORIENTATION to VERTICAL_ORIENTATION' , ( ) => {
991+ it . skip ( 'calls adjustDayPickerHeight if orientation has changed from HORIZONTAL_ORIENTATION to VERTICAL_ORIENTATION' , ( ) => {
994992 const wrapper = mount ( < DayPicker orientation = { HORIZONTAL_ORIENTATION } /> ) ;
995993 wrapper . setState ( {
996994 orientation : VERTICAL_ORIENTATION ,
997995 } ) ;
998996 expect ( adjustDayPickerHeightSpy ) . to . have . property ( 'callCount' , 2 ) ;
999997 } ) ;
1000998
1001- it ( 'calls adjustDayPickerHeight if daySize has changed' , ( ) => {
999+ it . skip ( 'calls adjustDayPickerHeight if daySize has changed' , ( ) => {
10021000 const wrapper = mount ( < DayPicker daySize = { 39 } orientation = { HORIZONTAL_ORIENTATION } /> ) ;
10031001 wrapper . setState ( {
10041002 daySize : 40 ,
@@ -1007,24 +1005,44 @@ describe('DayPicker', () => {
10071005 expect ( adjustDayPickerHeightSpy ) . to . have . property ( 'callCount' , 2 ) ;
10081006 } ) ;
10091007
1010- it ( 'calls updateStateAfterMonthTransition if state.monthTransition is truthy' , ( ) => {
1008+ it . skip ( 'calls updateStateAfterMonthTransition if state.monthTransition is truthy' , ( ) => {
10111009 const wrapper = mount ( < DayPicker orientation = { HORIZONTAL_ORIENTATION } /> ) ;
10121010 wrapper . setState ( {
10131011 monthTransition : 'foo' ,
10141012 } ) ;
10151013 expect ( updateStateAfterMonthTransitionSpy ) . to . have . property ( 'callCount' , 1 ) ;
10161014 } ) ;
10171015
1018- it ( 'does not call updateStateAfterMonthTransition if state.monthTransition is falsy' , ( ) => {
1016+ it . skip ( 'does not call updateStateAfterMonthTransition if state.monthTransition is falsy' , ( ) => {
10191017 const wrapper = mount ( < DayPicker orientation = { HORIZONTAL_ORIENTATION } /> ) ;
10201018 wrapper . setState ( {
10211019 monthTransition : null ,
10221020 } ) ;
10231021 expect ( updateStateAfterMonthTransitionSpy . calledOnce ) . to . equal ( false ) ;
10241022 } ) ;
1023+
1024+ it ( 'calls adjustDayPickerHeightSpy if props.numberOfMonths changes' , ( ) => {
1025+ const wrapper = shallow ( < DayPicker numberOfMonths = { 2 } /> ) . dive ( ) ;
1026+ wrapper . instance ( ) . componentDidUpdate ( {
1027+ daySize : DAY_SIZE ,
1028+ numberOfMonths : 3 ,
1029+ orientation : HORIZONTAL_ORIENTATION ,
1030+ } ) ;
1031+ expect ( adjustDayPickerHeightSpy . callCount ) . to . equal ( 1 ) ;
1032+ } ) ;
1033+
1034+ it ( 'does not call adjustDayPickerHeightSpy if props.numberOfMonths does not change' , ( ) => {
1035+ const wrapper = shallow ( < DayPicker numberOfMonths = { 2 } /> ) . dive ( ) ;
1036+ wrapper . instance ( ) . componentDidUpdate ( {
1037+ daySize : DAY_SIZE ,
1038+ numberOfMonths : 2 ,
1039+ orientation : HORIZONTAL_ORIENTATION ,
1040+ } ) ;
1041+ expect ( adjustDayPickerHeightSpy . called ) . to . equal ( false ) ;
1042+ } ) ;
10251043 } ) ;
10261044
1027- describe ( 'props.orientation === VERTICAL_ORIENTATION' , ( ) => {
1045+ describe . skip ( 'props.orientation === VERTICAL_ORIENTATION' , ( ) => {
10281046 it ( 'does not call adjustDayPickerHeight if state.monthTransition is truthy' , ( ) => {
10291047 const wrapper = mount ( < DayPicker orientation = { VERTICAL_ORIENTATION } /> ) ;
10301048 wrapper . setState ( {
@@ -1075,7 +1093,7 @@ describe('DayPicker', () => {
10751093 } ) ;
10761094 } ) ;
10771095
1078- describe ( 'props.orientation === VERTICAL_SCROLLABLE' , ( ) => {
1096+ describe . skip ( 'props.orientation === VERTICAL_SCROLLABLE' , ( ) => {
10791097 it ( 'does not update transitionContainer ref`s scrollTop currentMonth stays the same' , ( ) => {
10801098 sinon . spy ( DayPicker . prototype , 'setTransitionContainerRef' ) ;
10811099 const wrapper = mount ( < DayPicker orientation = { VERTICAL_SCROLLABLE } /> ) ;
@@ -1097,7 +1115,7 @@ describe('DayPicker', () => {
10971115 } ) ;
10981116 } ) ;
10991117
1100- describe ( 'when isFocused is updated to true' , ( ) => {
1118+ describe . skip ( 'when isFocused is updated to true' , ( ) => {
11011119 const prevProps = { isFocused : false } ;
11021120 const newProps = { isFocused : true } ;
11031121
0 commit comments