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

fix(connectRange): use refine instead of cleanUp in metadata #526

Merged
merged 2 commits into from
Oct 24, 2017
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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