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

Commit

Permalink
fix(connectRange): use refine instead of cleanUp in metadata (#526)
Browse files Browse the repository at this point in the history
  • Loading branch information
samouss authored and mthuret committed Oct 24, 2017
1 parent 1e4ffb2 commit 1861235
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 5 deletions.
3 changes: 2 additions & 1 deletion packages/react-instantsearch/src/connectors/connectRange.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,8 @@ export default createConnector({
items.push({
label: fragments.join(''),
attributeName: props.attributeName,
value: nextState => cleanUp(props, nextState, this.context),
value: nextState =>
refine(props, nextState, {}, this._currentRange, this.context),
currentRefinement: {
min: minValue,
max: maxValue,
Expand Down
52 changes: 48 additions & 4 deletions packages/react-instantsearch/src/connectors/connectRange.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,15 @@ describe('connectRange', () => {
const searchState = metadata.items[0].value({
range: { wot: { min: 5 } },
});
expect(searchState).toEqual({ range: {} });
expect(searchState).toEqual({
page: 1,
range: {
wot: {
min: undefined,
max: undefined,
},
},
});

metadata = connect.getMetadata.call(
{
Expand Down Expand Up @@ -532,7 +540,18 @@ describe('connectRange', () => {
range: { one: { min: 5 }, two: { max: 4 } },
});

expect(searchState).toEqual({ range: { two: { max: 4 } } });
expect(searchState).toEqual({
page: 1,
range: {
two: {
max: 4,
},
one: {
min: undefined,
max: undefined,
},
},
});
});

it('should return the right searchState when clean up', () => {
Expand Down Expand Up @@ -699,7 +718,19 @@ describe('connectRange', () => {
const searchState = metadata.items[0].value({
indices: { first: { range: { wot: { min: 5 } } } },
});
expect(searchState).toEqual({ indices: { first: { range: {} } } });
expect(searchState).toEqual({
indices: {
first: {
page: 1,
range: {
wot: {
min: undefined,
max: undefined,
},
},
},
},
});

metadata = connect.getMetadata.call(
{
Expand Down Expand Up @@ -752,7 +783,20 @@ describe('connectRange', () => {
});

expect(searchState).toEqual({
indices: { first: { range: { two: { max: 4 } } } },
indices: {
first: {
page: 1,
range: {
one: {
min: undefined,
max: undefined,
},
two: {
max: 4,
},
},
},
},
});
});

Expand Down

0 comments on commit 1861235

Please sign in to comment.