Skip to content

Commit

Permalink
Add range picker tests for next/prev callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Meed committed Aug 8, 2017
1 parent a8f1156 commit f346e9a
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions test/components/DayPickerRangeController_spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1988,7 +1988,7 @@ describe('DayPickerRangeController', () => {
expect(getModifiersSpy.callCount).to.equal(1);
});

it('calls props.onPrevMonthClick', () => {
it('calls props.onPrevMonthClick with new month', () => {
const onPrevMonthClickStub = sinon.stub();
const wrapper = shallow(
<DayPickerRangeController
Expand All @@ -1997,8 +1997,14 @@ describe('DayPickerRangeController', () => {
onPrevMonthClick={onPrevMonthClickStub}
/>,
);
wrapper.setState({
currentMonth: today,
});
const newMonth = moment().subtract(1, 'month');
wrapper.instance().onPrevMonthClick();
expect(onPrevMonthClickStub.callCount).to.equal(1);
expect(onPrevMonthClickStub.firstCall.args[0].year()).to.equal(newMonth.year());
expect(onPrevMonthClickStub.firstCall.args[0].month()).to.equal(newMonth.month());
});
});

Expand Down Expand Up @@ -2064,7 +2070,7 @@ describe('DayPickerRangeController', () => {
expect(getModifiersSpy.callCount).to.equal(1);
});

it('calls props.onNextMonthClick', () => {
it('calls props.onNextMonthClick with new month', () => {
const onNextMonthClickStub = sinon.stub();
const wrapper = shallow(
<DayPickerRangeController
Expand All @@ -2073,8 +2079,14 @@ describe('DayPickerRangeController', () => {
onNextMonthClick={onNextMonthClickStub}
/>,
);
wrapper.setState({
currentMonth: today,
});
const newMonth = moment().add(1, 'month');
wrapper.instance().onNextMonthClick();
expect(onNextMonthClickStub.callCount).to.equal(1);
expect(onNextMonthClickStub.firstCall.args[0].year()).to.equal(newMonth.year());
expect(onNextMonthClickStub.firstCall.args[0].month()).to.equal(newMonth.month());
});
});

Expand Down

0 comments on commit f346e9a

Please sign in to comment.