@@ -134,6 +134,8 @@ describe('DayPickerNavigation', () => {
134134 expect ( onPrevMonthStub ) . to . have . property ( 'callCount' , 1 ) ;
135135 prevMonthButton . simulate ( 'keyup' , { key : ' ' } ) ;
136136 expect ( onPrevMonthStub ) . to . have . property ( 'callCount' , 2 ) ;
137+ prevMonthButton . simulate ( 'keyup' , { key : 'k' } ) ;
138+ expect ( onPrevMonthStub ) . to . have . property ( 'callCount' , 2 ) ;
137139 } ) ;
138140
139141 it ( 'props.onNextMonthClick is triggered by next month button key up' , ( ) => {
@@ -145,6 +147,8 @@ describe('DayPickerNavigation', () => {
145147 expect ( onNextMonthStub ) . to . have . property ( 'callCount' , 1 ) ;
146148 nextMonthButton . simulate ( 'keyup' , { key : ' ' } ) ;
147149 expect ( onNextMonthStub ) . to . have . property ( 'callCount' , 2 ) ;
150+ nextMonthButton . simulate ( 'keyup' , { key : 'k' } ) ;
151+ expect ( onNextMonthStub ) . to . have . property ( 'callCount' , 2 ) ;
148152 } ) ;
149153
150154 it ( 'props.onPrevMonthClick is triggered by custom prev month button click' , ( ) => {
@@ -192,5 +196,35 @@ describe('DayPickerNavigation', () => {
192196 nextMonthButton . simulate ( 'click' ) ;
193197 expect ( onNextMonthStub ) . to . have . property ( 'callCount' , 0 ) ;
194198 } ) ;
199+
200+ it ( 'props.onPrevMonthClick is triggered by custom prev month button key up' , ( ) => {
201+ const onPrevMonthStub = sinon . stub ( ) ;
202+ const renderNavPrevButtonStub = sinon . stub ( ) . onCall ( 0 ) . callsFake ( ( { onKeyUp } ) => < button onKeyUp = { onKeyUp } type = "button" > Prev</ button > ) ;
203+ const prevMonthButton = shallow ( < DayPickerNavigation
204+ onPrevMonthClick = { onPrevMonthStub }
205+ renderNavPrevButton = { renderNavPrevButtonStub }
206+ /> ) . dive ( ) . find ( 'button' ) . at ( 0 ) ;
207+ prevMonthButton . simulate ( 'keyup' , { key : 'Enter' } ) ;
208+ expect ( onPrevMonthStub ) . to . have . property ( 'callCount' , 1 ) ;
209+ prevMonthButton . simulate ( 'keyup' , { key : ' ' } ) ;
210+ expect ( onPrevMonthStub ) . to . have . property ( 'callCount' , 2 ) ;
211+ prevMonthButton . simulate ( 'keyup' , { key : 'k' } ) ;
212+ expect ( onPrevMonthStub ) . to . have . property ( 'callCount' , 2 ) ;
213+ } ) ;
214+
215+ it ( 'props.onNextMonthClick is triggered by custom next month button key up' , ( ) => {
216+ const onNextMonthStub = sinon . stub ( ) ;
217+ const renderNavNextButtonStub = sinon . stub ( ) . onCall ( 0 ) . callsFake ( ( { onKeyUp } ) => < button onKeyUp = { onKeyUp } type = "button" > Next</ button > ) ;
218+ const nextMonthButton = shallow ( < DayPickerNavigation
219+ onNextMonthClick = { onNextMonthStub }
220+ renderNavNextButton = { renderNavNextButtonStub }
221+ /> ) . dive ( ) . find ( 'button' ) . at ( 0 ) ;
222+ nextMonthButton . simulate ( 'keyup' , { key : 'Enter' } ) ;
223+ expect ( onNextMonthStub ) . to . have . property ( 'callCount' , 1 ) ;
224+ nextMonthButton . simulate ( 'keyup' , { key : ' ' } ) ;
225+ expect ( onNextMonthStub ) . to . have . property ( 'callCount' , 2 ) ;
226+ nextMonthButton . simulate ( 'keyup' , { key : 'k' } ) ;
227+ expect ( onNextMonthStub ) . to . have . property ( 'callCount' , 2 ) ;
228+ } ) ;
195229 } ) ;
196230} ) ;
0 commit comments