Skip to content

Commit

Permalink
fix: tests for correct behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
kkmch committed Oct 11, 2023
1 parent f078983 commit 96d08cc
Showing 1 changed file with 7 additions and 24 deletions.
31 changes: 7 additions & 24 deletions src/blocks/Slider/__tests__/Slider.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,30 +41,13 @@ describe('Slider', () => {
const barDotsCount = CARDS_COUNT - slidesToShow + 1;

// Checking labels for the first slide
if (slidesToShow > 1) {
// There we have a bar covering `slidesToShow` dots
// eslint-disable-next-line testing-library/no-container, testing-library/no-node-access
const accessibleBarElement = container.querySelector('.pc-SliderBlock__accessible-bar');
expect(accessibleBarElement?.getAttribute('aria-label')).toBe(
`Slide 1 of ${barDotsCount}`,
);
expect(
queryHelpers.queryAllByAttribute(
'aria-label',
container,
`Slide 1 of ${barDotsCount}`,
),
).toHaveLength(slidesToShow + 1);
} else {
// There is no bar covering dots
expect(
queryHelpers.queryAllByAttribute(
'aria-label',
container,
`Slide 1 of ${barDotsCount}`,
),
).toHaveLength(1);
}
// There we have a bar covering `slidesToShow` dots
// eslint-disable-next-line testing-library/no-container, testing-library/no-node-access
const accessibleBarElement = container.querySelector('.pc-SliderBlock__accessible-bar');
expect(accessibleBarElement?.getAttribute('aria-label')).toBe(`Slide 1 of ${barDotsCount}`);
expect(
queryHelpers.queryAllByAttribute('aria-label', container, `Slide 1 of ${barDotsCount}`),
).toHaveLength(slidesToShow + 1);

// Checking labels for the slides starting from 2
Array(barDotsCount - 1)
Expand Down

0 comments on commit 96d08cc

Please sign in to comment.