Skip to content
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.

Commit

Permalink
fix(getDisjunctiveRefinements): remove error (#725)
Browse files Browse the repository at this point in the history
The condition is there to prevent a refinement of a non-declared facet, however we should just return the empty state there instead ([]).

See #722
  • Loading branch information
Haroenv committed Nov 18, 2019
1 parent e15e39e commit 211e390
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
4 changes: 1 addition & 3 deletions src/SearchParameters/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -547,9 +547,7 @@ SearchParameters.prototype = {
*/
getDisjunctiveRefinements: function(facetName) {
if (!this.isDisjunctiveFacet(facetName)) {
throw new Error(
facetName + ' is not defined in the disjunctiveFacets attribute of the helper configuration'
);
return [];
}
return this.disjunctiveFacetsRefinements[facetName] || [];
},
Expand Down
24 changes: 24 additions & 0 deletions test/spec/SearchParameters/getDisjunctiveRefinements.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
'use strict';

var SearchParameters = require('../../../src/SearchParameters');

test('getDisjunctiveRefinements returns value in facets', function() {
var state = new SearchParameters({
disjunctiveFacets: ['test'],
disjunctiveFacetsRefinements: {
test: ['zongo']
}
});

expect(state.getDisjunctiveRefinements('test')).toEqual(['zongo']);
});

test('getDisjunctiveRefinements returns [] if facet is not disjunctive', function() {
var state = new SearchParameters({
disjunctiveFacetsRefinements: {
test: ['zongo']
}
});

expect(state.getDisjunctiveRefinements('test')).toEqual([]);
});

0 comments on commit 211e390

Please sign in to comment.