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

Commit

Permalink
fix(MultiIndex): handle if namespace isn't in search state (#139)
Browse files Browse the repository at this point in the history
  • Loading branch information
mthuret authored Jun 26, 2017
1 parent 124ffe6 commit 1aab324
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/react-instantsearch/src/core/indexUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ export function getCurrentRefinementValue(
(hasMultipleIndex(context) &&
searchState.indices &&
namespace &&
searchState.indices[`${index}`] &&
has(searchState.indices[`${index}`][namespace], `${attributeName}`)) ||
(hasMultipleIndex(context) &&
searchState.indices &&
Expand Down
13 changes: 12 additions & 1 deletion packages/react-instantsearch/src/core/indexUtils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ describe('utility method for manipulating the search state', () => {
},
};

expect.assertions(6); //async assertions
expect.assertions(7); //async assertions

let expectedRefinement = value => expect(value).toEqual('refinement');

Expand Down Expand Up @@ -414,6 +414,17 @@ describe('utility method for manipulating the search state', () => {

expect(value).toEqual('defaultValue');

value = getCurrentRefinementValue(
{},
searchState,
context,
'anotherNamespace.refinement.top',
'defaultValue',
() => {}
);

expect(value).toEqual('defaultValue');

value = getCurrentRefinementValue(
{ defaultRefinement: 'defaultRefinement' },
{},
Expand Down

0 comments on commit 1aab324

Please sign in to comment.