import { render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { describe, it, expect } from 'vitest'; import { Carrusel } from '../Carrusel'; describe('', () => { it('renders every slide', () => { render(Uno

,

Dos

,

Tres

]} />); expect(screen.getByText('Uno')).toBeInTheDocument(); expect(screen.getByText('Dos')).toBeInTheDocument(); expect(screen.getByText('Tres')).toBeInTheDocument(); }); it('renders one position dot per slide, and marks the current one', () => { render(Uno

,

Dos

]} />); const dots = screen.getAllByRole('button', { name: /ir a la tarjeta/i }); expect(dots).toHaveLength(2); expect(dots[0]).toHaveAttribute('aria-current', 'true'); }); it('moves to a slide when its dot is clicked', async () => { const user = userEvent.setup(); render(Uno

,

Dos

]} />); const dots = screen.getAllByRole('button', { name: /ir a la tarjeta/i }); await user.click(dots[1]); expect(dots[1]).toHaveAttribute('aria-current', 'true'); }); it('hides the dots entirely for a single slide', () => { render(Solo una

]} />); expect(screen.queryByRole('button', { name: /ir a la tarjeta/i })).not.toBeInTheDocument(); }); it('exposes the slide group with the given accessible name', () => { render(Uno

]} />); expect(screen.getByRole('group', { name: 'Frases de ejemplo' })).toBeInTheDocument(); }); it('shows a numbered counter with prev/next arrows instead of dots when mostrarContador is set', () => { render(Uno

,

Dos

,

Tres

]} />); expect(screen.getByText('01')).toBeInTheDocument(); expect(screen.getByText(/\/ 03/)).toBeInTheDocument(); expect(screen.getByRole('button', { name: 'Siguiente' })).toBeInTheDocument(); expect(screen.getByRole('button', { name: 'Anterior' })).toBeInTheDocument(); expect(screen.queryByRole('button', { name: /ir a la tarjeta/i })).not.toBeInTheDocument(); }); it('advances the counter when the next arrow is clicked', async () => { const user = userEvent.setup(); render(Uno

,

Dos

]} />); await user.click(screen.getByRole('button', { name: 'Siguiente' })); expect(screen.getByText('02')).toBeInTheDocument(); }); });