Skip to content

Commit

Permalink
Implement data-testid prop
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekmaj committed Jan 12, 2023
1 parent b3ec397 commit 2ebe92d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ Displays an input field complete with custom inputs, native input, and a calenda
| clearIcon | Content of the clear button. Setting the value explicitly to `null` will hide the icon. | (default icon) | <ul><li>String: `"Clear"`</li><li>React element: `<ClearIcon />`</li></ul> |
| clockClassName | Class name(s) that will be added along with `"react-clock"` to the main React-Calendar `<div>` element. | n/a | <ul><li>String: `"class1 class2"`</li><li>Array of strings: `["class1", "class2 class3"]`</li></ul> |
| closeWidgets | Whether to close the widgets on value selection. | `true` | `false` |
| data-testid | `data-testid` attribute for the main React-DateTimeRange-Picker `<div>` element. | n/a | `"date-picker"` |
| dayAriaLabel | `aria-label` for the day input. | n/a | `"Day"` |
| disabled | Whether the datetime range picker should be disabled. | `false` | `true` |
| disableCalendar | When set to `true`, will remove the calendar and the button toggling its visibility. | `false` | `true` |
Expand Down
4 changes: 3 additions & 1 deletion src/DateTimeRangePicker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ export default class DateTimeRangePicker extends PureComponent {

render() {
const { eventProps } = this;
const { className, disabled } = this.props;
const { className, 'data-testid': dataTestid, disabled } = this.props;
const { isCalendarOpen, isClockOpen } = this.state;

const { onChange, ...eventPropsWithoutOnChange } = eventProps;
Expand All @@ -509,6 +509,7 @@ export default class DateTimeRangePicker extends PureComponent {
`${baseClassName}--${disabled ? 'disabled' : 'enabled'}`,
className,
)}
data-testid={dataTestid}
{...eventPropsWithoutOnChange}
onFocus={this.onFocus}
ref={this.wrapper}
Expand Down Expand Up @@ -576,6 +577,7 @@ DateTimeRangePicker.propTypes = {
clearIcon: PropTypes.node,
clockClassName: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
closeWidgets: PropTypes.bool,
'data-testid': PropTypes.string,
dayAriaLabel: PropTypes.string,
dayPlaceholder: PropTypes.string,
disableCalendar: PropTypes.bool,
Expand Down
1 change: 1 addition & 0 deletions test/Test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export default function Test() {
<DateTimeRangePicker
calendarClassName="myCustomCalendarClassName"
className="myCustomDateTimeRangePickerClassName"
data-testid="myCustomDateTimeRangePicker"
disabled={disabled}
locale={locale}
maxDate={maxDate}
Expand Down

0 comments on commit 2ebe92d

Please sign in to comment.