import { render, screen } from '@testing-library/react';
import { describe, it, expect } from 'vitest';
import { Dolores } from '../Dolores';
import { dolores } from '@/lib/content';
describe('', () => {
it('renders the four pains verbatim, in the client\'s first person', () => {
render();
for (const dolor of dolores.quotes) {
expect(screen.getAllByText(new RegExp(dolor.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))).length).toBeGreaterThan(0);
}
});
it('says each pain only once out loud, however many times it is painted', () => {
const { container } = render();
// The drifting rows repeat the four sentences four times over: twice per
// row so the loop has no seam, and twice again because there are two rows.
// Only one of those runs may reach assistive tech — otherwise a screen
// reader recites the whole list of pains, and then recites it again.
for (const dolor of dolores.quotes) {
const apariciones = Array.from(container.querySelectorAll('span')).filter(
(el) => el.textContent?.includes(dolor),
);
const audibles = apariciones.filter((el) => !el.closest('[aria-hidden="true"]'));
expect(apariciones.length).toBeGreaterThan(1);
expect(audibles).toHaveLength(1);
}
});
it('closes with the resolution, not with more effort', () => {
const { container } = render();
expect(container.textContent).toContain('Esto no se resuelve con más esfuerzo.');
expect(container.textContent).toContain('Se resuelve con una estrategia clara.');
});
it('centres the knot so the conductor thread runs through it', () => {
const { container } = render();
// The knot is the centred decorative svg of the section; the conductor
// thread runs down the centre, so only a centred knot gets traversed by
// it — stitching the pain to the resolution below.
const centrados = Array.from(container.querySelectorAll('svg')).filter((s) => {
const cls = s.getAttribute('class') ?? '';
return cls.includes('left-1/2') && cls.includes('-translate-x-1/2');
});
expect(centrados.length).toBeGreaterThanOrEqual(1);
});
it('does NOT introduce scarcity', () => {
const { container } = render();
expect(container.textContent).not.toMatch(/cupos|cohorte|generación fundadora/i);
});
});