Skip to content

Commit

Permalink
feat(sort-by-selector): currentValue -> currentRefinement
Browse files Browse the repository at this point in the history
  • Loading branch information
iam4x committed Mar 27, 2017
1 parent 7e86be3 commit e94c8c7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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'},
Expand All @@ -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'},
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions src/connectors/sort-by-selector/connectSortBySelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -65,7 +65,7 @@ export default function connectSortBySelector(renderFn) {
.search();

renderFn({
currentValue: currentIndex,
currentRefinement: currentIndex,
options: selectorOptions,
refine: this.setIndex,
hasNoResults: true,
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/sort-by-selector/sort-by-selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const renderer = ({
cssClasses,
autoHideContainer,
}) => ({
currentValue,
currentRefinement,
options,
refine,
hasNoResults,
Expand All @@ -25,7 +25,7 @@ const renderer = ({
ReactDOM.render(
<Selector
cssClasses={cssClasses}
currentValue={currentValue}
currentValue={currentRefinement}
options={options}
setValue={refine}
shouldAutoHideContainer={shouldAutoHideContainer}
Expand Down

0 comments on commit e94c8c7

Please sign in to comment.