From e94c8c79038cedfa4eddfa11a80199626ada0b83 Mon Sep 17 00:00:00 2001 From: iam4x Date: Mon, 27 Mar 2017 17:43:35 +0200 Subject: [PATCH] feat(sort-by-selector): `currentValue` -> `currentRefinement` --- .../__tests__/connectSortBySelector-test.js | 16 ++++++++-------- .../sort-by-selector/connectSortBySelector.js | 8 ++++---- src/widgets/sort-by-selector/sort-by-selector.js | 4 ++-- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/connectors/sort-by-selector/__tests__/connectSortBySelector-test.js b/src/connectors/sort-by-selector/__tests__/connectSortBySelector-test.js index c087a11e4c..9d27a67ffc 100644 --- a/src/connectors/sort-by-selector/__tests__/connectSortBySelector-test.js +++ b/src/connectors/sort-by-selector/__tests__/connectSortBySelector-test.js @@ -38,8 +38,8 @@ describe('connectSortBySelector', () => { expect(isFirstRendering).toBe(true); // should provide good values for the first rendering - const {currentValue, options, widgetParams} = rendering.lastCall.args[0]; - expect(currentValue).toBe(helper.state.index); + const {currentRefinement, options, widgetParams} = rendering.lastCall.args[0]; + expect(currentRefinement).toBe(helper.state.index); expect(widgetParams).toEqual({indices}); expect(options).toEqual([ {label: 'Sort products by relevance', value: 'relevance'}, @@ -60,8 +60,8 @@ describe('connectSortBySelector', () => { expect(isFirstRendering).toBe(false); // should provide good values after the first search - const {currentValue, options} = rendering.lastCall.args[0]; - expect(currentValue).toBe(helper.state.index); + const {currentRefinement, options} = rendering.lastCall.args[0]; + expect(currentRefinement).toBe(helper.state.index); expect(options).toEqual([ {label: 'Sort products by relevance', value: 'relevance'}, {label: 'Sort products by price', value: 'priceASC'}, @@ -94,8 +94,8 @@ describe('connectSortBySelector', () => { { // first rendering expect(helper.state.index).toBe(indices[0].name); const renderOptions = rendering.lastCall.args[0]; - const {refine, currentValue} = renderOptions; - expect(currentValue).toBe(helper.state.index); + const {refine, currentRefinement} = renderOptions; + expect(currentRefinement).toBe(helper.state.index); refine('bip'); expect(helper.state.index).toBe('bip'); expect(helper.search.callCount).toBe(1); @@ -111,8 +111,8 @@ describe('connectSortBySelector', () => { { // Second rendering expect(helper.state.index).toBe('bip'); const renderOptions = rendering.lastCall.args[0]; - const {refine, currentValue} = renderOptions; - expect(currentValue).toBe('bip'); + const {refine, currentRefinement} = renderOptions; + expect(currentRefinement).toBe('bip'); refine('bop'); expect(helper.state.index).toBe('bop'); expect(helper.search.callCount).toBe(2); diff --git a/src/connectors/sort-by-selector/connectSortBySelector.js b/src/connectors/sort-by-selector/connectSortBySelector.js index 6205600936..a82c42b913 100644 --- a/src/connectors/sort-by-selector/connectSortBySelector.js +++ b/src/connectors/sort-by-selector/connectSortBySelector.js @@ -3,7 +3,7 @@ import {checkRendering} from '../../lib/utils.js'; const usage = `Usage: var customSortBySelector = connectSortBySelector(function render(params, isFirstRendering) { // params = { - // currentValue, + // currentRefinement, // options, // refine, // hasNoResults, @@ -26,7 +26,7 @@ Full documentation available at https://community.algolia.com/instantsearch.js/c /** * @typedef {Object} SortBySelectorRenderingOptions - * @property {string} currentValue the currently selected index + * @property {string} currentRefinement the currently selected index * @property {Object[]} options all the available indices * @property {function} refine switch indices and do a new search * @property {boolean} hasNoResults a boolean that indicates if there were no results during that last search @@ -65,7 +65,7 @@ export default function connectSortBySelector(renderFn) { .search(); renderFn({ - currentValue: currentIndex, + currentRefinement: currentIndex, options: selectorOptions, refine: this.setIndex, hasNoResults: true, @@ -76,7 +76,7 @@ export default function connectSortBySelector(renderFn) { render({helper, results, instantSearchInstance}) { renderFn({ - currentValue: helper.getIndex(), + currentRefinement: helper.getIndex(), options: selectorOptions, refine: this.setIndex, hasNoResults: results.nbHits === 0, diff --git a/src/widgets/sort-by-selector/sort-by-selector.js b/src/widgets/sort-by-selector/sort-by-selector.js index 5b96aa8038..cdd70ecfbe 100644 --- a/src/widgets/sort-by-selector/sort-by-selector.js +++ b/src/widgets/sort-by-selector/sort-by-selector.js @@ -13,7 +13,7 @@ const renderer = ({ cssClasses, autoHideContainer, }) => ({ - currentValue, + currentRefinement, options, refine, hasNoResults, @@ -25,7 +25,7 @@ const renderer = ({ ReactDOM.render(