Skip to content

Commit

Permalink
fix(relevantSort): rename smartSort to relevantSort (#4668)
Browse files Browse the repository at this point in the history
  • Loading branch information
Eunjae Lee authored Mar 3, 2021
1 parent 264da66 commit 579eee8
Show file tree
Hide file tree
Showing 14 changed files with 221 additions and 221 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

### Bug Fixes

* **smartSort:** export the widget and the connector ([#4663](https://github.com/algolia/instantsearch.js/issues/4663)) ([e7aaa8c](https://github.com/algolia/instantsearch.js/commit/e7aaa8ceb47b8cafc3a3a323ebe47f45f3841ba4))
* **relevantSort:** export the widget and the connector ([#4663](https://github.com/algolia/instantsearch.js/issues/4663)) ([e7aaa8c](https://github.com/algolia/instantsearch.js/commit/e7aaa8ceb47b8cafc3a3a323ebe47f45f3841ba4))


### Features
Expand All @@ -17,7 +17,7 @@

### Features

* **smartSort:** add widget ([#4648](https://github.com/algolia/instantsearch.js/issues/4648)) ([89c6e86](https://github.com/algolia/instantsearch.js/commit/89c6e868f490e9b6e507dd70c215e962f4c69ccb))
* **relevantSort:** add widget ([#4648](https://github.com/algolia/instantsearch.js/issues/4648)) ([89c6e86](https://github.com/algolia/instantsearch.js/commit/89c6e868f490e9b6e507dd70c215e962f4c69ccb))
* **stats:** apply nbSortedHits ([#4649](https://github.com/algolia/instantsearch.js/issues/4649)) ([34478c1](https://github.com/algolia/instantsearch.js/commit/34478c198dcafbd45fd101db0cd2fbe6328272b8))
* **ts:** convert menu ([#4652](https://github.com/algolia/instantsearch.js/issues/4652)) ([2271b43](https://github.com/algolia/instantsearch.js/commit/2271b4379918e865a1b0cea09c139e517df97bc5))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@
import { h } from 'preact';
import Template from '../Template/Template';
import {
SmartSortCSSClasses,
SmartSortTemplates,
} from '../../widgets/smart-sort/smart-sort';
RelevantSortCSSClasses,
RelevantSortTemplates,
} from '../../widgets/relevant-sort/relevant-sort';

type SmartSortProps = {
cssClasses: SmartSortCSSClasses;
templates: SmartSortTemplates;
isSmartSorted: boolean;
type RelevantSortProps = {
cssClasses: RelevantSortCSSClasses;
templates: RelevantSortTemplates;
isRelevantSorted: boolean;
isVirtualReplica: boolean;
refine(relevancyStrictness: number | undefined): void;
};

const SmartSort = ({
const RelevantSort = ({
cssClasses,
templates,
isSmartSorted,
isRelevantSorted,
isVirtualReplica,
refine,
}: SmartSortProps) =>
}: RelevantSortProps) =>
isVirtualReplica ? (
<div className={cssClasses.root}>
<Template
Expand All @@ -30,13 +30,13 @@ const SmartSort = ({
rootProps={{
className: cssClasses.text,
}}
data={{ isSmartSorted }}
data={{ isRelevantSorted }}
/>
<button
type="button"
className={cssClasses.button}
onClick={() => {
if (isSmartSorted) {
if (isRelevantSorted) {
refine(0);
} else {
refine(undefined);
Expand All @@ -47,10 +47,10 @@ const SmartSort = ({
rootTagName="span"
templateKey="button"
templates={templates}
data={{ isSmartSorted }}
data={{ isRelevantSorted }}
/>
</button>
</div>
) : null;

export default SmartSort;
export default RelevantSort;
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { h } from 'preact';
import { render, fireEvent } from '@testing-library/preact';

import SmartSort from '../SmartSort';
import RelevantSort from '../RelevantSort';

const cssClasses = {
root: 'root',
Expand All @@ -13,18 +13,18 @@ const cssClasses = {

const templates = {
text: '',
button: ({ isSmartSorted }) => {
return isSmartSorted ? 'See all results' : 'See relevant results';
button: ({ isRelevantSorted }) => {
return isRelevantSorted ? 'See all results' : 'See relevant results';
},
};

describe('SmartSort', () => {
describe('RelevantSort', () => {
it('render nothing if not virtual replica', () => {
const { container } = render(
<SmartSort
<RelevantSort
cssClasses={cssClasses}
templates={templates}
isSmartSorted={false}
isRelevantSorted={false}
isVirtualReplica={false}
refine={() => {}}
/>
Expand All @@ -34,10 +34,10 @@ describe('SmartSort', () => {

it('render the default status', () => {
const { container } = render(
<SmartSort
<RelevantSort
cssClasses={cssClasses}
templates={templates}
isSmartSorted={false}
isRelevantSorted={false}
isVirtualReplica={true}
refine={() => {}}
/>
Expand Down Expand Up @@ -66,10 +66,10 @@ describe('SmartSort', () => {
it('refine on button click', () => {
const refine = jest.fn();
const { getByText } = render(
<SmartSort
<RelevantSort
cssClasses={cssClasses}
templates={templates}
isSmartSorted={false}
isRelevantSorted={false}
isVirtualReplica={true}
refine={refine}
/>
Expand All @@ -80,10 +80,10 @@ describe('SmartSort', () => {

it('render sorted status', () => {
const { container } = render(
<SmartSort
<RelevantSort
cssClasses={cssClasses}
templates={templates}
isSmartSorted={true}
isRelevantSorted={true}
isVirtualReplica={true}
refine={() => {}}
/>
Expand Down Expand Up @@ -112,10 +112,10 @@ describe('SmartSort', () => {
it('refine with `undefined` on "See relevant results"', () => {
const refine = jest.fn();
const { getByText } = render(
<SmartSort
<RelevantSort
cssClasses={cssClasses}
templates={templates}
isSmartSorted={false}
isRelevantSorted={false}
isVirtualReplica={true}
refine={refine}
/>
Expand All @@ -128,10 +128,10 @@ describe('SmartSort', () => {
it('refine with `0` on "Seeing all results"', () => {
const refine = jest.fn();
const { getByText } = render(
<SmartSort
<RelevantSort
cssClasses={cssClasses}
templates={templates}
isSmartSorted={true}
isRelevantSorted={true}
isVirtualReplica={true}
refine={refine}
/>
Expand Down
2 changes: 1 addition & 1 deletion src/connectors/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ export { default as connectAutocomplete } from './autocomplete/connectAutocomple
export { default as connectQueryRules } from './query-rules/connectQueryRules';
export { default as connectVoiceSearch } from './voice-search/connectVoiceSearch';
export { default as EXPERIMENTAL_connectAnswers } from './answers/connectAnswers';
export { default as connectSmartSort } from './smart-sort/connectSmartSort';
export { default as connectRelevantSort } from './relevant-sort/connectRelevantSort';
Loading

0 comments on commit 579eee8

Please sign in to comment.