Skip to content

Commit

Permalink
Adding unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
guidosreis committed Dec 13, 2021
1 parent bcb781b commit 546a545
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions test/components/DayPickerRangeController_spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3693,6 +3693,40 @@ describe('DayPickerRangeController', () => {
});
});

describe.only('#onMonchChange', () => {
it('sets disableNext as false when maxDate is in visible month and a past month is selected', () => {
const wrapper = shallow((
<DayPickerRangeController
onDatesChange={sinon.stub()}
onFocusChange={sinon.stub()}
maxDate={today}
/>
));
wrapper.setState({
currentMonth: today,
});
expect(wrapper.state().disableNext).to.equal(true);
wrapper.instance().onMonthChange(today.clone().subtract(1, 'month'));
expect(wrapper.state().disableNext).to.equal(false);
});

it('sets disablePrev as false when minDate is in visible month and a future month is selected', () => {
const wrapper = shallow((
<DayPickerRangeController
onDatesChange={sinon.stub()}
onFocusChange={sinon.stub()}
minDate={today}
/>
));
wrapper.setState({
currentMonth: today,
});
expect(wrapper.state().disablePrev).to.equal(true);
wrapper.instance().onMonthChange(today.clone().add(1, 'month'));
expect(wrapper.state().disablePrev).to.equal(false);
});
});

describe('#getFirstFocusableDay', () => {
describe('focusedInput === START_DATE', () => {
it('returns startDate if exists and is not blocked', () => {
Expand Down

0 comments on commit 546a545

Please sign in to comment.