-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Transactions table description search (#853)
- Loading branch information
Showing
9 changed files
with
224 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React from 'react'; | ||
import { render, screen, waitFor } from '@testing-library/react'; | ||
import { userEvent } from '@testing-library/user-event'; | ||
|
||
import SearchBox from '@/components/SearchBox'; | ||
|
||
describe('SearchBox', () => { | ||
it('calls debounced on change', async () => { | ||
const onChange = jest.fn(); | ||
render(<SearchBox onChange={onChange} />); | ||
|
||
const input = screen.getByRole('textbox'); | ||
await userEvent.type(input, 'text'); | ||
|
||
await waitFor(() => expect(onChange).toBeCalledTimes(1)); | ||
expect(onChange).toBeCalledWith('text'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import React from 'react'; | ||
import debounce from 'lodash.debounce'; | ||
|
||
export type SearchBoxProps = { | ||
onChange: Function, | ||
}; | ||
|
||
export default function SearchBox({ | ||
onChange, | ||
}: SearchBoxProps): JSX.Element { | ||
const debounced = debounce( | ||
(e: React.ChangeEvent<HTMLInputElement>) => onChange(e.target?.value), | ||
500, | ||
); | ||
|
||
return ( | ||
<input | ||
onChange={debounced} | ||
placeholder="Search..." | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.