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

fix(ssr): add error when no indexName is passed #2842

Merged
merged 1 commit into from
Sep 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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