This repository was archived by the owner on Dec 30, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 8 files changed +55
-18
lines changed
packages/react-instantsearch-hooks/src Expand file tree Collapse file tree 8 files changed +55
-18
lines changed Original file line number Diff line number Diff line change @@ -3,14 +3,14 @@ import {
33 InstantSearch ,
44 InstantSearchSSRProvider ,
55 Index ,
6+ Configure ,
67} from 'react-instantsearch-hooks' ;
78import { simple } from 'instantsearch.js/es/lib/stateMappings' ;
89import { history } from 'instantsearch.js/es/lib/routers' ;
910
1011import { searchClient } from './searchClient' ;
1112
1213import {
13- Configure ,
1414 Highlight ,
1515 Hits ,
1616 Pagination ,
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 11import { Hit as AlgoliaHit } from '@algolia/client-search' ;
22import algoliasearch from 'algoliasearch/lite' ;
33import React from 'react' ;
4- import { InstantSearch , DynamicWidgets } from 'react-instantsearch-hooks' ;
4+ import {
5+ InstantSearch ,
6+ Configure ,
7+ DynamicWidgets ,
8+ } from 'react-instantsearch-hooks' ;
59
610import {
711 ClearRefinements ,
8- Configure ,
912 CurrentRefinements ,
1013 HierarchicalMenu ,
1114 Highlight ,
Original file line number Diff line number Diff line change 11export * from './ClearRefinements' ;
2- export * from './Configure' ;
32export * from './CurrentRefinements' ;
43export * from './HierarchicalMenu' ;
54export * from './Highlight' ;
Original file line number Diff line number Diff line change 1- import { useConfigure , UseConfigureProps } from 'react-instantsearch-hooks' ;
1+ import { useConfigure } from '../connectors/useConfigure' ;
2+
3+ import type { UseConfigureProps } from '../connectors/useConfigure' ;
24
35export type ConfigureProps = UseConfigureProps ;
46
Original file line number Diff line number Diff line change 1+ import { act , render , waitFor } from '@testing-library/react' ;
2+ import React from 'react' ;
3+
4+ import { createSearchClient } from '../../../../../test/mock' ;
5+ import { Configure } from '../Configure' ;
6+ import { InstantSearch } from '../InstantSearch' ;
7+
8+ describe ( 'Configure' , ( ) => {
9+ test ( 'does not render anything' , ( ) => {
10+ const searchClient = createSearchClient ( ) ;
11+
12+ const { container } = render (
13+ < InstantSearch indexName = "indexName" searchClient = { searchClient } >
14+ < Configure hitsPerPage = { 666 } />
15+ </ InstantSearch >
16+ ) ;
17+
18+ expect ( container ) . toMatchInlineSnapshot ( `<div />` ) ;
19+ } ) ;
20+
21+ test ( 'sets search parameters' , async ( ) => {
22+ const searchClient = createSearchClient ( ) ;
23+
24+ act ( ( ) => {
25+ render (
26+ < InstantSearch indexName = "indexName" searchClient = { searchClient } >
27+ < Configure hitsPerPage = { 666 } />
28+ </ InstantSearch >
29+ ) ;
30+ } ) ;
31+
32+ await waitFor ( ( ) => {
33+ expect ( searchClient . search ) . toHaveBeenCalledTimes ( 1 ) ;
34+ expect ( searchClient . search ) . toHaveBeenCalledWith ( [
35+ {
36+ indexName : 'indexName' ,
37+ params : expect . objectContaining ( {
38+ hitsPerPage : 666 ,
39+ } ) ,
40+ } ,
41+ ] ) ;
42+ } ) ;
43+ } ) ;
44+ } ) ;
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import { render } from '@testing-library/react';
22import React , { createRef } from 'react' ;
33
44import { createSearchClient } from '../../../../../test/mock' ;
5- import { useConfigure } from '../../connectors/useConfigure ' ;
5+ import { Configure } from '../../components/Configure ' ;
66import { IndexContext } from '../../lib/IndexContext' ;
77import { noop } from '../../lib/noop' ;
88import { Index } from '../Index' ;
@@ -11,11 +11,6 @@ import { InstantSearchSSRProvider } from '../InstantSearchSSRProvider';
1111
1212import type { IndexWidget } from 'instantsearch.js/es/widgets/index/index' ;
1313
14- function Configure ( props ) {
15- useConfigure ( props ) ;
16- return null ;
17- }
18-
1914describe ( 'Index' , ( ) => {
2015 test ( 'throws when used outside of <InstantSearch>' , ( ) => {
2116 // Hide the errors from the test logs.
Original file line number Diff line number Diff line change 11export { default as version } from './version' ;
2+ export * from './components/Configure' ;
23export * from './components/DynamicWidgets' ;
34export * from './components/Index' ;
45export * from './components/InstantSearch' ;
You can’t perform that action at this time.
0 commit comments