Skip to content

Commit

Permalink
Add defaultValue prop to Search component (#2211)
Browse files Browse the repository at this point in the history
Co-authored-by: Maria <8730830+1Maria@users.noreply.github.com>
  • Loading branch information
gidjin and 1Maria authored Nov 8, 2022
1 parent f5bf2e7 commit 6ad525b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/components/Search/Search.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@ describe('Search component', () => {
)
})

it('renders a default value', () => {
const mockSubmit = jest.fn()
const defaultValue = 'Search here'
const { queryByTestId } = render(
<Search onSubmit={mockSubmit} defaultValue={defaultValue}></Search>
)
expect(queryByTestId('textInput')).toHaveAttribute(
'value',
defaultValue
)
})

it('renders a label', () => {
const mockSubmit = jest.fn()
const { queryByLabelText } = render(
Expand Down
1 change: 1 addition & 0 deletions src/components/Search/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export const Search = ({
type="search"
name={inputName}
placeholder={placeholder}
defaultValue={formProps.defaultValue}
/>
<Button type="submit">
{!isSmall && (
Expand Down

0 comments on commit 6ad525b

Please sign in to comment.