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

Commit

Permalink
fix(ssr): add error when no indexName is passed (#2842)
Browse files Browse the repository at this point in the history
  • Loading branch information
Haroenv authored and samouss committed Sep 24, 2019
1 parent 3f26109 commit 3cac5c4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,20 @@ describe('findResultsState', () => {
);
});

it('throws an error if props does not have an `indexName`', () => {
const App = () => <div />;

const props = {
searchClient: createSearchClient(),
};

const trigger = () => findResultsState(App, props);

expect(() => trigger()).toThrowErrorMatchingInlineSnapshot(
`"The props provided to \`findResultsState\` must have an \`indexName\`"`
);
});

it('adds expected Algolia agents', () => {
const App = props => <InstantSearch {...props} />;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ export const findResultsState = function(App, props) {
);
}

if (!props.indexName) {
throw new Error(
'The props provided to `findResultsState` must have an `indexName`'
);
}

const { indexName, searchClient } = props;

const searchParameters = [];
Expand Down

0 comments on commit 3cac5c4

Please sign in to comment.