Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

Commit

Permalink
feat(connectStateResults): expose isSearchStalled through the connector
Browse files Browse the repository at this point in the history
  • Loading branch information
samouss committed Feb 2, 2018
1 parent c39c19b commit b571f7a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { getResults } from '../core/indexUtils';
* @providedPropType {object} allSearchResults - In case of multiple indices you can retrieve all the results
* @providedPropType {string} error - If the search failed, the error will be logged here.
* @providedPropType {boolean} searching - If there is a search in progress.
* @providedPropType {boolean} isSearchStalled - Flag that indicates if React InstantSearch has detected that searches are stalled.
* @providedPropType {boolean} searchingForFacetValues - If there is a search in a list in progress.
* @providedPropType {object} props - component props.
* @example
Expand Down Expand Up @@ -46,11 +47,13 @@ export default createConnector({

getProvidedProps(props, searchState, searchResults) {
const results = getResults(searchResults, this.context);

return {
searchState,
searchResults: results,
allSearchResults: searchResults.results,
searching: searchResults.searching,
isSearchStalled: searchResults.isSearchStalled,
error: searchResults.error,
searchingForFacetValues: searchResults.searchingForFacetValues,
props,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,25 @@ describe('connectStateResults', () => {
const searchState = { state: 'state' };
const error = 'error';
const searching = true;
const isSearchStalled = true;
const searchingForFacetValues = true;
const searchResults = {
results: { nbHits: 25, hits: [] },
error,
searching,
isSearchStalled,
searchingForFacetValues,
};

const expectation = {
searchState,
searchResults: searchResults.results,
allSearchResults: searchResults.results,
props: { props: 'props' },
error,
searching,
isSearchStalled,
searchingForFacetValues,
props: { props: 'props' },
};

const actual = getProvidedProps(
Expand All @@ -58,6 +61,7 @@ describe('connectStateResults', () => {
const searchState = { state: 'state' };
const error = 'error';
const searching = true;
const isSearchStalled = true;
const searchingForFacetValues = true;
const searchResults = {
results: {
Expand All @@ -66,17 +70,19 @@ describe('connectStateResults', () => {
},
error,
searching,
isSearchStalled,
searchingForFacetValues,
};

const expectation = {
searchState,
searchResults: searchResults.results.first,
allSearchResults: searchResults.results,
props: { props: 'props' },
error,
searching,
isSearchStalled,
searchingForFacetValues,
props: { props: 'props' },
};

const actual = getProvidedProps(
Expand Down

0 comments on commit b571f7a

Please sign in to comment.