Skip to content

Commit 5286c7c

Browse files
francoischalifourbobylito
authored andcommitted
fix(searchFunction): Fix unresolved returned Promise (#2913)
* fix(searchFunction): Fix unresolved returned Promise * test(searchFunction): Test `searchFunction` with multiple requests
1 parent 545355f commit 5286c7c

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/lib/InstantSearch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ Usage: instantsearch({
314314
helper.search = () => {
315315
const helperSearchFunction = algoliasearchHelper(
316316
{
317-
search: () => Promise.resolve({ results: [{}] }),
317+
search: () => new Promise(() => {}),
318318
},
319319
helper.state.index,
320320
helper.state

src/lib/__tests__/InstantSearch-test-2.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,4 +159,24 @@ describe('InstantSearch life cycle', () => {
159159

160160
jest.runAllTimers();
161161
});
162+
163+
it('does not break when providing searchFunction with multiple resquests', () => {
164+
const search = new InstantSearch({
165+
appId,
166+
apiKey,
167+
indexName,
168+
searchFunction: h => {
169+
h.addDisjunctiveFacetRefinement('brand', 'Apple');
170+
h.search();
171+
},
172+
searchParameters: {
173+
disjunctiveFacetsRefinements: { brand: ['Apple'] },
174+
disjunctiveFacets: ['brand'],
175+
},
176+
});
177+
178+
expect(() => {
179+
search.start();
180+
}).not.toThrow();
181+
});
162182
});

0 commit comments

Comments
 (0)