Skip to content
Snippets Groups Projects
Commit a21d3f0c authored by Erin Doyle's avatar Erin Doyle
Browse files

Added a regression unit test for the miss of passing onClose from...

Added a regression unit test for the miss of passing onClose from SingleDatePicker to DayPickerSingleDateController as well as examples of using onClose with SingleDatePicker and DateRangePicker.
parent f30a1a15
No related branches found
No related tags found
No related merge requests found
......@@ -66,6 +66,7 @@ const defaultProps = {
navNext: null,
onPrevMonthClick() {},
onNextMonthClick() {},
onClose() {},
// day presentation and interaction related props
renderDay: null,
......
......@@ -57,6 +57,7 @@ const defaultProps = {
navNext: null,
onPrevMonthClick() {},
onNextMonthClick() {},
onClose() {},
// day presentation and interaction related props
renderDay: null,
......
......@@ -165,4 +165,10 @@ storiesOf('DRP - Calendar Props', module)
firstDayOfWeek={3}
autoFocus
/>
))
.addWithInfo('with onClose handler', () => (
<DateRangePickerWrapper
onClose={({ startDate, endDate }) => alert(`onClose: startDate = ${startDate}, endDate = ${endDate}`)}
autoFocus
/>
));
......@@ -146,5 +146,11 @@ storiesOf('SDP - Calendar Props', module)
firstDayOfWeek={3}
autoFocus
/>
))
.addWithInfo('with onClose handler', () => (
<SingleDatePickerWrapper
onClose={({ date }) => alert(`onClose: date = ${date}`)}
autoFocus
/>
));
......@@ -60,6 +60,22 @@ describe('SingleDatePicker', () => {
expect(wrapper.find(DayPickerSingleDateController)).to.have.lengthOf(0);
});
});
describe('props.onClose is defined', () => {
it('should pass props.onClose in to <DayPickerSingleDateController>', () => {
const onCloseStub = sinon.stub();
const wrapper = shallow((
<SingleDatePicker
id="date"
onDateChange={() => {}}
onFocusChange={() => {}}
focused
onClose={onCloseStub}
/>
)).dive();
expect(wrapper.find(DayPickerSingleDateController).prop('onClose')).to.equal(onCloseStub);
});
});
});
describe('props.withPortal is truthy', () => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment