feat(dolores): el nudo que no se deshace
This commit is contained in:
1 parent
0239d4ac15
commit
2fa1e73764
3 files changed
+100
-2
No files matched your search
@@ -0,0 +1,48 @@
|
||||
import { render } from '@testing-library/react';
|
||||
import { describe, it, expect, afterEach } from 'vitest';
|
||||
import { IlustracionNudo } from '../IlustracionNudo';
|
||||
|
||||
describe('<IlustracionNudo />', () => {
|
||||
const matchMediaOriginal = window.matchMedia;
|
||||
afterEach(() => {
|
||||
window.matchMedia = matchMediaOriginal;
|
||||
});
|
||||
|
||||
it('is decorative: hidden from assistive tech', () => {
|
||||
const { container } = render(<IlustracionNudo />);
|
||||
const svg = container.querySelector('svg');
|
||||
expect(svg).toHaveAttribute('aria-hidden', 'true');
|
||||
expect(svg).toHaveAttribute('focusable', 'false');
|
||||
});
|
||||
|
||||
it('tangles several strands rather than drawing one line', () => {
|
||||
const { container } = render(<IlustracionNudo />);
|
||||
expect(container.querySelectorAll('path').length).toBeGreaterThanOrEqual(3);
|
||||
});
|
||||
|
||||
it('renders plain, fully-visible strands under reduced motion instead of motion.path\'s dash scaffolding', () => {
|
||||
// Force the reduced-motion branch. motion.path applies stroke-dasharray/
|
||||
// stroke-dashoffset even with no explicit initial/animate resolution,
|
||||
// which leaves the drawing invisible for reduced-motion users — see
|
||||
// lib/motion.ts. The reduced branch must use plain <path> elements
|
||||
// instead, so none of them should carry that dash scaffolding.
|
||||
window.matchMedia = (query: string) =>
|
||||
({
|
||||
matches: true,
|
||||
media: query,
|
||||
onchange: null,
|
||||
addEventListener: () => {},
|
||||
removeEventListener: () => {},
|
||||
addListener: () => {},
|
||||
removeListener: () => {},
|
||||
dispatchEvent: () => false,
|
||||
}) as unknown as MediaQueryList;
|
||||
|
||||
const { container } = render(<IlustracionNudo />);
|
||||
const paths = container.querySelectorAll('path');
|
||||
expect(paths.length).toBeGreaterThanOrEqual(3);
|
||||
paths.forEach((path) => {
|
||||
expect(path).not.toHaveAttribute('stroke-dasharray');
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user