react-day-picker update tests to include new use of Element or React.SFC for captionElement

This commit is contained in:
cwmoo740
2017-03-09 15:22:54 -05:00
parent d57893528c
commit c0b6319ccf
+20 -3
View File
@@ -8,7 +8,7 @@ function isSunday(day: Date) {
function MyComponent() {
return (
<DayPicker
ref="foo" initialMonth={ new Date(2016, 1) } localeUtils={DayPicker.LocaleUtils} modifiers={{ isSunday }}
initialMonth={ new Date(2016, 1) } localeUtils={DayPicker.LocaleUtils} modifiers={{ isSunday }}
/>
);
}
@@ -26,10 +26,27 @@ class Caption extends React.Component<MyCaptionProps, {}> {
}
return (
<div className="DayPicker-Caption" onClick={ (e) => onClick(date, e) }>
<div className="DayPicker-Caption" onClick={ onClick }>
{ localeUtils.formatMonthTitle(date, locale) }
</div>
);
}
}
<DayPicker captionElement={<Caption/>}/>
<DayPicker captionElement={ Caption }/>
type CaptionElementProps = Partial<DayPicker.CaptionElementProps>;
class CaptionElement extends React.Component<CaptionElementProps, {}> {
render() {
const { date, locale, localeUtils, onClick } = this.props;
if (!date || !locale || !localeUtils || !onClick) {
return <div/>;
}
return (
<div onClick={ onClick }>
{ localeUtils.formatMonthTitle(date, locale) }
</div>
)
}
}
<DayPicker captionElement={ <CaptionElement /> }/>