Files
Creeer-Web/components/primitives/__tests__/Revelar.test.tsx
T
erikghandClaude Opus 5.5 89e54a6e84 feat: rediseño «El documento» en curso, contacto real y enlaces externos
Primitivas y contenido del rediseño (escala tipográfica, Revelar,
MarcaSeccion, Seccion, Antetitulo, SimboloMarca, Resplandor, ClaridadHero,
sección Proceso de ocho etapas, lib/content.ts reestructurado en seis
secciones con alias para las viejas). Mecanismo y FormaTrabajar se retiran.

Encima, lo de esta sesión:
- recorrido: creeer vuelve a responder cada situación en vez de repetirla
  (el alias apuntaba respuesta a situacion); respuestas en plural. Créditos
  de las seis fotos de México.
- contacto: WhatsApp, email (con mailto:) y LinkedIn reales; iconos de las
  redes en el cierre y el footer (IconoRed, trazos de Simple Icons, CC0).
- enlaces: lo externo abre en otra pestaña con noopener y aviso para
  lectores de pantalla (lib/enlaces.ts); mailto y anclas se quedan.
- Proceso: las ocho tarjetas no aparecían nunca en móvil (amount 0.3 sobre
  una lista de ~3000px); ahora cada una se revela sola. El ≡ de la 08 ya no
  tapa un entregable, título equilibrado, etiqueta a 12px, sin elevar al
  hover lo que no es clicable.
- Disciplinas: la frase «No son la promesa — son los medios» gana peso y
  se agrupa con título e ilustración; sin cortes huérfanos en móvil.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 11:27:20 -06:00

53 lines
2.0 KiB
TypeScript

import { render, screen } from '@testing-library/react';
import { describe, it, expect, beforeEach, vi } from 'vitest';
import { Revelar } from '../Revelar';
// The stub in vitest.setup.ts is inert: it observes but never fires. This one
// captures the callback so we can simulate the element entering the viewport.
let disparar: (entradas: Partial<IntersectionObserverEntry>[]) => void;
beforeEach(() => {
vi.stubGlobal(
'IntersectionObserver',
class {
constructor(cb: IntersectionObserverCallback) {
disparar = (entradas) => cb(entradas as IntersectionObserverEntry[], this as never);
}
observe() {}
unobserve() {}
disconnect() {}
},
);
});
describe('<Revelar />', () => {
it('no oculta nada por sí mismo', () => {
// The hidden state is CSS-only, gated on `html.js`. If the component wrote
// opacity 0 into the inline style we'd be back to the bug this redesign
// fixes: 112 invisible elements in the export and a blank page whenever
// the JS doesn't arrive.
const { container } = render(<Revelar>Tu negocio no necesita más esfuerzo.</Revelar>);
const el = container.firstElementChild as HTMLElement;
expect(el.style.opacity).toBe('');
expect(screen.getByText('Tu negocio no necesita más esfuerzo.')).toBeInTheDocument();
});
it('marca el bloque para que el CSS lo pueda gobernar', () => {
const { container } = render(<Revelar>x</Revelar>);
expect(container.firstElementChild).toHaveAttribute('data-revelar');
});
it('escalona el retardo con el índice', () => {
const { container } = render(<Revelar indice={3}>x</Revelar>);
expect((container.firstElementChild as HTMLElement).style.getPropertyValue('--i')).toBe('3');
});
it('se marca visible al entrar en viewport', () => {
const { container } = render(<Revelar>x</Revelar>);
const el = container.firstElementChild as HTMLElement;
expect(el).not.toHaveAttribute('data-visible');
disparar([{ isIntersecting: true, target: el }]);
expect(el).toHaveAttribute('data-visible');
});
});