From 96d08cccfe526b58bff16d16f275308e3178682f Mon Sep 17 00:00:00 2001 From: kkmch Date: Wed, 11 Oct 2023 18:11:13 +0200 Subject: [PATCH] fix: tests for correct behaviour --- src/blocks/Slider/__tests__/Slider.test.tsx | 31 +++++---------------- 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/src/blocks/Slider/__tests__/Slider.test.tsx b/src/blocks/Slider/__tests__/Slider.test.tsx index 0d0b7e335..9c0a3e7d5 100644 --- a/src/blocks/Slider/__tests__/Slider.test.tsx +++ b/src/blocks/Slider/__tests__/Slider.test.tsx @@ -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)