Skip to content

Commit

Permalink
Fix broken test
Browse files Browse the repository at this point in the history
  • Loading branch information
Kris Salvador committed Apr 14, 2019
1 parent 98fd20b commit d847a91
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 21 deletions.
29 changes: 14 additions & 15 deletions src/components/DayPickerRangeController.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,21 +113,21 @@ const defaultProps = {
endDate: undefined, // TODO: use null
minDate: null,
maxDate: null,
onDatesChange() { },
onDatesChange() {},
startDateOffset: undefined,
endDateOffset: undefined,

focusedInput: null,
onFocusChange() { },
onClose() { },
onFocusChange() {},
onClose() {},

keepOpenOnDateSelect: false,
minimumNights: 1,
disabled: false,
isOutsideRange() { },
isDayBlocked() { },
isDayHighlighted() { },
getMinNightsForHoverDate() { },
isOutsideRange() {},
isDayBlocked() {},
isDayHighlighted() {},
getMinNightsForHoverDate() {},

// DayPicker props
renderMonthText: null,
Expand All @@ -143,9 +143,9 @@ const defaultProps = {
navNext: null,
noNavButtons: false,

onPrevMonthClick() { },
onNextMonthClick() { },
onOutsideClick() { },
onPrevMonthClick() {},
onNextMonthClick() {},
onOutsideClick() {},

renderCalendarDay: undefined,
renderDayContents: null,
Expand All @@ -161,11 +161,11 @@ const defaultProps = {
horizontalMonthPadding: 13,

// accessibility
onBlur() { },
onBlur() {},
isFocused: false,
showKeyboardShortcuts: false,
onTab() { },
onShiftTab() { },
onTab() {},
onShiftTab() {},

// i18n
monthFormat: 'MMMM YYYY',
Expand Down Expand Up @@ -727,8 +727,7 @@ export default class DayPickerRangeController extends React.PureComponent {

if (endDate) {
const startSpan = endDate.clone().subtract(minimumNights, 'days');
const endSpan = endDate.clone();
modifiers = this.deleteModifierFromRange(modifiers, startSpan, endSpan, 'before-hovered-end');
modifiers = this.deleteModifierFromRange(modifiers, startSpan, endDate, 'before-hovered-end');

if (isSameDay(day, endDate)) {
const newStartSpan = endDate.clone().subtract(minimumNights, 'days');
Expand Down
15 changes: 9 additions & 6 deletions test/components/DayPickerRangeController_spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ describe('DayPickerRangeController', () => {
describe('#componentDidMount', () => {
const props = {
...DayPickerRangeController.defaultProps,
onDatesChange() {},
onFocusChange() {},
onDatesChange() { },
onFocusChange() { },
};

describe('phrases', () => {
Expand Down Expand Up @@ -98,8 +98,8 @@ describe('DayPickerRangeController', () => {
describe('#componentWillReceiveProps', () => {
const props = {
...DayPickerRangeController.defaultProps,
onDatesChange() {},
onFocusChange() {},
onDatesChange() { },
onFocusChange() { },
};

describe('rebuilding currentMonth/visibleDays', () => {
Expand Down Expand Up @@ -2306,10 +2306,13 @@ describe('DayPickerRangeController', () => {
wrapper.setState({ hoverDate });
deleteModifierFromRangeSpy.resetHistory();
wrapper.instance().onDayMouseEnter(moment().add(10, 'days'));
expect(deleteModifierFromRangeSpy.callCount).to.equal(1);
expect(deleteModifierFromRangeSpy.callCount).to.equal(2);
expect(deleteModifierFromRangeSpy.getCall(0).args[1]).to.equal(hoverDate);
expect(deleteModifierFromRangeSpy.getCall(0).args[2]).to.equal(endDate);
expect(deleteModifierFromRangeSpy.getCall(0).args[3]).to.equal('hovered-span');
expect(isSameDay(deleteModifierFromRangeSpy.getCall(1).args[1], endDate.subtract(DayPickerRangeController.defaultProps.minimumNights, 'days'))).to.equal(true);
expect(deleteModifierFromRangeSpy.getCall(1).args[2]).to.equal(endDate);
expect(deleteModifierFromRangeSpy.getCall(1).args[3]).to.equal('before-hovered-end');
});
});

Expand Down Expand Up @@ -4429,7 +4432,7 @@ describe('DayPickerRangeController', () => {

describe('renderKeyboardShortcutsButton prop', () => {
it('pass down custom button render function', () => {
const testRenderKeyboardShortcutsButton = () => {};
const testRenderKeyboardShortcutsButton = () => { };
const wrapper = shallow(
<DayPickerRangeController
renderKeyboardShortcutsButton={testRenderKeyboardShortcutsButton}
Expand Down

0 comments on commit d847a91

Please sign in to comment.