This repository has been archived by the owner on Dec 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 391
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(hooks): introduce
<Configure>
(#3261)
- Loading branch information
1 parent
b8b5d07
commit 3527b94
Showing
8 changed files
with
55 additions
and
18 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 was deleted.
Oops, something went wrong.
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
4 changes: 3 additions & 1 deletion
4
examples/hooks/components/Configure.tsx → ...search-hooks/src/components/Configure.tsx
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
44 changes: 44 additions & 0 deletions
44
packages/react-instantsearch-hooks/src/components/__tests__/Configure.test.tsx
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,44 @@ | ||
import { act, render, waitFor } from '@testing-library/react'; | ||
import React from 'react'; | ||
|
||
import { createSearchClient } from '../../../../../test/mock'; | ||
import { Configure } from '../Configure'; | ||
import { InstantSearch } from '../InstantSearch'; | ||
|
||
describe('Configure', () => { | ||
test('does not render anything', () => { | ||
const searchClient = createSearchClient(); | ||
|
||
const { container } = render( | ||
<InstantSearch indexName="indexName" searchClient={searchClient}> | ||
<Configure hitsPerPage={666} /> | ||
</InstantSearch> | ||
); | ||
|
||
expect(container).toMatchInlineSnapshot(`<div />`); | ||
}); | ||
|
||
test('sets search parameters', async () => { | ||
const searchClient = createSearchClient(); | ||
|
||
act(() => { | ||
render( | ||
<InstantSearch indexName="indexName" searchClient={searchClient}> | ||
<Configure hitsPerPage={666} /> | ||
</InstantSearch> | ||
); | ||
}); | ||
|
||
await waitFor(() => { | ||
expect(searchClient.search).toHaveBeenCalledTimes(1); | ||
expect(searchClient.search).toHaveBeenCalledWith([ | ||
{ | ||
indexName: 'indexName', | ||
params: expect.objectContaining({ | ||
hitsPerPage: 666, | ||
}), | ||
}, | ||
]); | ||
}); | ||
}); | ||
}); |
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