File tree Expand file tree Collapse file tree 2 files changed +42
-6
lines changed
Expand file tree Collapse file tree 2 files changed +42
-6
lines changed Original file line number Diff line number Diff line change @@ -274,9 +274,45 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/pagination/
274274 const makeWidget = connectPagination ( renderFn ) ;
275275 const widget = makeWidget ( ) ;
276276
277- const nextConfiguation = widget . getConfiguration ( ) ;
277+ const nextConfiguation = widget . getConfiguration (
278+ new SearchParameters ( { } )
279+ ) ;
280+
281+ expect ( nextConfiguation ) . toEqual (
282+ new SearchParameters ( {
283+ page : 0 ,
284+ } )
285+ ) ;
286+ } ) ;
278287
279- expect ( nextConfiguation . page ) . toBe ( 0 ) ;
288+ it ( 'takes the previous `page` from the `SearchParameters`' , ( ) => {
289+ const renderFn = ( ) => { } ;
290+ const makeWidget = connectPagination ( renderFn ) ;
291+ const widget = makeWidget ( ) ;
292+
293+ const nextConfiguation1 = widget . getConfiguration (
294+ new SearchParameters ( {
295+ page : 0 ,
296+ } )
297+ ) ;
298+
299+ expect ( nextConfiguation1 ) . toEqual (
300+ new SearchParameters ( {
301+ page : 0 ,
302+ } )
303+ ) ;
304+
305+ const nextConfiguation2 = widget . getConfiguration (
306+ new SearchParameters ( {
307+ page : 6 ,
308+ } )
309+ ) ;
310+
311+ expect ( nextConfiguation2 ) . toEqual (
312+ new SearchParameters ( {
313+ page : 6 ,
314+ } )
315+ ) ;
280316 } ) ;
281317 } ) ;
282318
Original file line number Diff line number Diff line change @@ -100,10 +100,10 @@ export default function connectPagination(renderFn, unmountFn = noop) {
100100 return {
101101 $$type : 'ais.pagination' ,
102102
103- getConfiguration ( ) {
104- return {
105- page : 0 ,
106- } ;
103+ getConfiguration ( state ) {
104+ return state . setQueryParameters ( {
105+ page : state . page || 0 ,
106+ } ) ;
107107 } ,
108108
109109 init ( { helper, createURL, instantSearchInstance } ) {
You can’t perform that action at this time.
0 commit comments