Skip to content

Commit

Permalink
feat(refinementList): updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Davis committed Apr 21, 2023
1 parent 2c0b70f commit bf50452
Showing 1 changed file with 51 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ describe('ShowMoreButton', () => {
const { container } = render(
<ShowMoreButton
isShowingMore={false}
showMoreCount={0}
translations={defaultTranslations}
/>
);
Expand All @@ -34,7 +35,11 @@ describe('ShowMoreButton', () => {

test('changes the button label when is showing more', () => {
const { container } = render(
<ShowMoreButton isShowingMore={true} translations={defaultTranslations} />
<ShowMoreButton
isShowingMore={true}
showMoreCount={0}
translations={defaultTranslations}
/>
);

expect(container).toMatchInlineSnapshot(`
Expand All @@ -51,6 +56,7 @@ describe('ShowMoreButton', () => {
const { getByRole } = render(
<ShowMoreButton
isShowingMore={false}
showMoreCount={0}
onClick={onClick}
translations={defaultTranslations}
/>
Expand All @@ -66,6 +72,7 @@ describe('ShowMoreButton', () => {
const { container, getByRole } = render(
<ShowMoreButton
isShowingMore={false}
showMoreCount={0}
disabled={true}
onClick={onClick}
translations={defaultTranslations}
Expand Down Expand Up @@ -94,15 +101,56 @@ describe('ShowMoreButton', () => {
},
};
const { getByRole, rerender } = render(
<ShowMoreButton isShowingMore translations={translations} />
<ShowMoreButton
isShowingMore
showMoreCount={0}
translations={translations}
/>
);

expect(getByRole('button', { name: 'Display less' })).toBeInTheDocument();

rerender(
<ShowMoreButton isShowingMore={false} translations={translations} />
<ShowMoreButton
isShowingMore={false}
showMoreCount={0}
translations={translations}
/>
);

expect(getByRole('button', { name: 'Display more' })).toBeInTheDocument();
});

test('renders show more count', () => {
const translations = {
showMoreButtonText({
isShowingMore,
showMoreCount,
}: {
isShowingMore: boolean;
showMoreCount: number;
}) {
return isShowingMore ? 'Display less' : `Display ${showMoreCount} more`;
},
};
const { getByRole, rerender } = render(
<ShowMoreButton
isShowingMore
showMoreCount={5}
translations={translations}
/>
);

expect(getByRole('button', { name: 'Display less' })).toBeInTheDocument();

rerender(
<ShowMoreButton
isShowingMore={false}
showMoreCount={5}
translations={translations}
/>
);

expect(getByRole('button', { name: 'Display 5 more' })).toBeInTheDocument();
});
});

0 comments on commit bf50452

Please sign in to comment.