Skip to content

Commit b71c2a8

Browse files
committed
Update tests
1 parent ad6eaf4 commit b71c2a8

File tree

1 file changed

+6
-17
lines changed

1 file changed

+6
-17
lines changed

src/components/__tests__/search-bar.test.jsx

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,10 @@ describe('search-bar', () => {
4646

4747
it('Handles date range search queries for startDate', () => {
4848
const onSearch = jest.fn();
49-
render(<SearchBar inputIdSuffix="1" onSearch={onSearch} />);
50-
51-
// To open and interact with the calendar, we first need to focus the input it's attached to.
52-
const startDateInput = screen.getByLabelText(/start date/i);
53-
fireEvent.focus(startDateInput);
49+
render(<SearchBar onSearch={onSearch} />);
5450

55-
// The actual button text is something like "Choose Sunday, June 1, 2025, blah blah".
56-
// This should get us close enough. There will be more than one (for the current and previous month).
57-
const calendarDay = screen.getAllByRole('button', { name: /Choose .* 1,/ });
58-
fireEvent.click(calendarDay[0]);
51+
const startDateInput = screen.getByLabelText(/from date/i);
52+
fireEvent.change(startDateInput, { target: { value: '2025-06-01' } });
5953

6054
expect(onSearch).toHaveBeenCalledWith({
6155
url: null,
@@ -66,15 +60,10 @@ describe('search-bar', () => {
6660

6761
it('Handles date range search queries for endDate', () => {
6862
const onSearch = jest.fn();
69-
render(<SearchBar inputIdSuffix="1" onSearch={onSearch} />);
70-
71-
const endDateInput = screen.getByLabelText(/end date/i);
72-
fireEvent.focus(endDateInput);
63+
render(<SearchBar onSearch={onSearch} />);
7364

74-
// The actual button text is something like "Choose Sunday, June 1, 2025, blah blah".
75-
// This should get us close enough. There will be more than one (for the current and previous month).
76-
const calendarDay = screen.getAllByRole('button', { name: /Choose .* 1,/ });
77-
fireEvent.click(calendarDay[0]);
65+
const endDateInput = screen.getByLabelText(/to date/i);
66+
fireEvent.change(endDateInput, { target: { value: '2025-06-01' } });
7867

7968
expect(onSearch).toHaveBeenCalledWith({
8069
url: null,

0 commit comments

Comments
 (0)