Skip to content

Commit

Permalink
!fixup tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Haroenv committed Dec 20, 2024
1 parent 74518be commit eb71d75
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,9 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/clear-refin
clearRefinements({
container,
templates: {
resetLabel({ hasRefinements }, { html }) {
resetLabel({ canRefine }, { html }) {
return html`<span
>${hasRefinements
? 'Clear refinements'
: 'No refinements'}</span
>${canRefine ? 'Clear refinements' : 'No refinements'}</span
>`;
},
},
Expand Down Expand Up @@ -235,10 +233,10 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/clear-refin
clearRefinements({
container,
templates: {
resetLabel({ hasRefinements }) {
resetLabel({ canRefine }) {
return (
<span>
{hasRefinements ? 'Clear refinements' : 'No refinements'}
{canRefine ? 'Clear refinements' : 'No refinements'}
</span>
);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export type ClearRefinementsTemplates = Partial<{
/**
* Template for the content of the button
*/
resetLabel: Template<{ hasRefinements: boolean }>;
resetLabel: Template<{ canRefine: boolean }>;
}>;

export type ClearRefinementsWidgetParams = {
Expand Down
8 changes: 4 additions & 4 deletions packages/react-instantsearch/src/ui/CurrentRefinements.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export type CurrentRefinementsProps = React.ComponentProps<'div'> & {
> &
Record<string, unknown>
>;
hasRefinements?: boolean;
canRefine?: boolean;
};

export type CurrentRefinementsClassNames = {
Expand Down Expand Up @@ -59,7 +59,7 @@ export type CurrentRefinementsClassNames = {
export function CurrentRefinements({
classNames = {},
items = [],
hasRefinements = false,
canRefine = false,
...props
}: CurrentRefinementsProps) {
return (
Expand All @@ -68,7 +68,7 @@ export function CurrentRefinements({
className={cx(
'ais-CurrentRefinements',
classNames.root,
!hasRefinements &&
!canRefine &&
cx(
'ais-CurrentRefinements--noRefinement',
classNames.noRefinementRoot
Expand All @@ -81,7 +81,7 @@ export function CurrentRefinements({
'ais-CurrentRefinements-list',
classNames.list,
/* @MAJOR remove to ensure conformity with InstantSearch.css specs */
!hasRefinements &&
!canRefine &&
cx(
'ais-CurrentRefinements-list--noRefinement',
classNames.noRefinementList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('CurrentRefinements', () => {
],
},
]}
hasRefinements={true}
canRefine={true}
/>
);

Expand All @@ -72,7 +72,7 @@ describe('CurrentRefinements', () => {
>
Brand
:
</span>
<span
class="ais-CurrentRefinements-category"
Expand Down Expand Up @@ -203,7 +203,7 @@ describe('CurrentRefinements', () => {
>
Brand
:
</span>
<span
class="ais-CurrentRefinements-category CATEGORY"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ import { CurrentRefinements as CurrentRefinementsUiComponent } from '../ui/Curre
import type { CurrentRefinementsProps as CurrentRefinementsUiComponentProps } from '../ui/CurrentRefinements';
import type { UseCurrentRefinementsProps } from 'react-instantsearch-core';

type UiProps = Pick<
CurrentRefinementsUiComponentProps,
'items' | 'hasRefinements'
>;
type UiProps = Pick<CurrentRefinementsUiComponentProps, 'items' | 'canRefine'>;

export type CurrentRefinementsProps = Omit<
CurrentRefinementsUiComponentProps,
Expand All @@ -36,7 +33,7 @@ export function CurrentRefinements({

const uiProps: UiProps = {
items,
hasRefinements: canRefine,
canRefine,
};

return <CurrentRefinementsUiComponent {...props} {...uiProps} />;
Expand Down

0 comments on commit eb71d75

Please sign in to comment.