Skip to content

Commit

Permalink
Tests caught an oopsie!
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonLin0991 committed Nov 6, 2023
1 parent da75061 commit 3859f0d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,30 +191,34 @@ export const FilterDateRange = forwardRef(
const onStartDateChangeValidation = (date?: string) => {
if (date && validateDate(date)) {
setShowStartDateError(false)
startDatePickerOnChange(formatUserInputDate(date))
startDatePickerOnChange(formatUserInputDate(date.trimEnd()))
} else if (!date) {
startDatePickerOnChange(date)
}
}

const onEndDateChangeValidation = (date?: string) => {
if (date && validateDate(date)) {
setShowEndDateError(false)
endDatePickerOnChange(formatUserInputDate(date))
endDatePickerOnChange(formatUserInputDate(date.trimEnd()))
} else if (!date) {
endDatePickerOnChange(date)
}
}

const onStartDateBlurValidation = (event: DatePickerOnBlurType) => {
const e = event as React.FocusEvent<HTMLInputElement>
const date = e.target.value
if (date.length > 0) {
setShowStartDateError(!validateDate(date))
setShowStartDateError(!validateDate(date.trimEnd()))
}
}

const onEndDateBlurValidation = (event: DatePickerOnBlurType) => {
const e = event as React.FocusEvent<HTMLInputElement>
const date = e.target.value
if (date.length > 0) {
setShowEndDateError(!validateDate(date))
setShowEndDateError(!validateDate(date.trimEnd()))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,9 @@ describe('RateReviewsTable', () => {
await userEvent.click(accordionButton)
})

const ratingPeriodFilter = screen.getByTestId('date-range-picker')
const ratingPeriodFilter = screen.getByTestId(
'filter-date-range-picker'
)
const dateRangePickerInputs = within(
ratingPeriodFilter
).queryAllByTestId('date-picker-external-input')
Expand Down

0 comments on commit 3859f0d

Please sign in to comment.