Skip to content

Commit 998faf1

Browse files
committed
feat(connectors.numeric-selector): currentValue -> currentRefinement / setValue() -> refine()
1 parent 91f7928 commit 998faf1

File tree

3 files changed

+23
-23
lines changed

3 files changed

+23
-23
lines changed

src/connectors/numeric-selector/__tests__/connectNumericSelector-test.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ describe('connectNumericSelector', () => {
5151
expect(rendering.lastCall.args[1]).toBe(true);
5252

5353
const firstRenderingOptions = rendering.lastCall.args[0];
54-
expect(firstRenderingOptions.currentValue).toBe(listOptions[0].value);
54+
expect(firstRenderingOptions.currentRefinement).toBe(listOptions[0].value);
5555
expect(firstRenderingOptions.widgetParams).toEqual({
5656
attributeName: 'numerics',
5757
options: listOptions,
@@ -69,7 +69,7 @@ describe('connectNumericSelector', () => {
6969
expect(rendering.lastCall.args[1]).toBe(false);
7070

7171
const secondRenderingOptions = rendering.lastCall.args[0];
72-
expect(secondRenderingOptions.currentValue).toBe(listOptions[0].value);
72+
expect(secondRenderingOptions.currentRefinement).toBe(listOptions[0].value);
7373
expect(secondRenderingOptions.widgetParams).toEqual({
7474
attributeName: 'numerics',
7575
options: listOptions,
@@ -139,13 +139,13 @@ describe('connectNumericSelector', () => {
139139
});
140140

141141
const firstRenderingOptions = rendering.lastCall.args[0];
142-
const {setValue} = firstRenderingOptions;
142+
const {refine} = firstRenderingOptions;
143143
expect(helper.state.getNumericRefinements('numerics')).toEqual({'=': [10]});
144-
setValue(listOptions[1].name);
144+
refine(listOptions[1].name);
145145
expect(helper.state.getNumericRefinements('numerics')).toEqual({'=': [20]});
146-
setValue(listOptions[2].name);
146+
refine(listOptions[2].name);
147147
expect(helper.state.getNumericRefinements('numerics')).toEqual({'=': [30]});
148-
setValue(listOptions[0].name);
148+
refine(listOptions[0].name);
149149
expect(helper.state.getNumericRefinements('numerics')).toEqual({'=': [10]});
150150

151151
widget.render({
@@ -156,7 +156,7 @@ describe('connectNumericSelector', () => {
156156
});
157157

158158
const secondRenderingOptions = rendering.lastCall.args[0];
159-
const {setValue: renderSetValue} = secondRenderingOptions;
159+
const {refine: renderSetValue} = secondRenderingOptions;
160160
expect(helper.state.getNumericRefinements('numerics')).toEqual({'=': [10]});
161161
renderSetValue(listOptions[1].name);
162162
expect(helper.state.getNumericRefinements('numerics')).toEqual({'=': [20]});
@@ -190,12 +190,12 @@ describe('connectNumericSelector', () => {
190190
onHistoryChange: () => {},
191191
});
192192

193-
let setValue = rendering.lastCall.args[0].setValue;
193+
let refine = rendering.lastCall.args[0].refine;
194194

195195
listOptions.forEach((_, i) => {
196196
// we loop with 1 increment because the first value is selected by default
197197
const currentOption = listOptions[(i + 1) % listOptions.length];
198-
setValue(currentOption.name);
198+
refine(currentOption.name);
199199

200200
widget.render({
201201
results: new SearchResults(helper.state, [{}]),
@@ -209,9 +209,9 @@ describe('connectNumericSelector', () => {
209209
const expectedResult = currentOption.value;
210210

211211
const renderingParameters = rendering.lastCall.args[0];
212-
expect(renderingParameters.currentValue).toEqual(expectedResult);
212+
expect(renderingParameters.currentRefinement).toEqual(expectedResult);
213213

214-
setValue = renderingParameters.setValue;
214+
refine = renderingParameters.refine;
215215
});
216216
});
217217
});

src/connectors/numeric-selector/connectNumericSelector.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import {checkRendering} from '../../lib/utils.js';
33
const usage = `Usage:
44
var customNumericSelector = connectNumericSelector(function renderFn(params, isFirstRendering) {
55
// params = {
6-
// currentValue,
6+
// currentRefinement,
77
// options,
8-
// setValue,
8+
// refine,
99
// hasNoResults,
1010
// instantSearchInstance,
1111
// widgetParams,
@@ -32,9 +32,9 @@ Full documentation available at https://community.algolia.com/instantsearch.js/c
3232

3333
/**
3434
* @typedef {Object} NumericSelectorRenderingOptions
35-
* @property {string} currentValue the currently selected value
35+
* @property {string} currentRefinement the currently selected value
3636
* @property {{ value: string, label: string }[]} the different values and labels of the selector
37-
* @property {function} setValue updates the change with the selected value
37+
* @property {function} refine updates the change with the selected value
3838
* @property {boolean} hasNoResults indicates if the last search returned any value
3939
* @property {InstantSearch} instantSearchInstance the instance of instantsearch on which the widget is attached
4040
* @property {Object} widgetParams all original options forwarded to rendering
@@ -80,9 +80,9 @@ export default function connectNumericSelector(renderFn) {
8080
};
8181

8282
renderFn({
83-
currentValue: this._getRefinedValue(helper.state),
83+
currentRefinement: this._getRefinedValue(helper.state),
8484
options,
85-
setValue: this._refine,
85+
refine: this._refine,
8686
hasNoResults: true,
8787
instantSearchInstance,
8888
widgetParams,
@@ -91,9 +91,9 @@ export default function connectNumericSelector(renderFn) {
9191

9292
render({helper, results, instantSearchInstance}) {
9393
renderFn({
94-
currentValue: this._getRefinedValue(helper.state),
94+
currentRefinement: this._getRefinedValue(helper.state),
9595
options,
96-
setValue: this._refine,
96+
refine: this._refine,
9797
hasNoResults: results.nbHits === 0,
9898
instantSearchInstance,
9999
widgetParams,

src/widgets/numeric-selector/numeric-selector.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ const renderer = ({
1717
autoHideContainer,
1818
cssClasses,
1919
}) => ({
20-
currentValue,
21-
setValue,
20+
currentRefinement,
21+
refine,
2222
hasNoResults,
2323
options,
2424
}, isFirstRendering) => {
@@ -27,9 +27,9 @@ const renderer = ({
2727
ReactDOM.render(
2828
<Selector
2929
cssClasses={cssClasses}
30-
currentValue={currentValue}
30+
currentValue={currentRefinement}
3131
options={options}
32-
setValue={setValue}
32+
setValue={refine}
3333
shouldAutoHideContainer={autoHideContainer && hasNoResults}
3434
/>,
3535
containerNode

0 commit comments

Comments
 (0)