Files
portifolio-evandrodevbr/app/hooks/useReducedMotion.test.ts
T
Evandro Fonseca Junior 08dd046887 feat: add animated components for enhanced UI/UX
- Introduced DrawLine component for drawing animations.
- Added LazyRevealImage component for lazy loading images with reveal animations.
- Implemented TextDiffuseReveal for animated text reveals with staggered effects.
- Created TopProgressBar for a dynamic loading indicator.
- Added PointCloud mock for testing animations.
- Developed useReducedMotion hook to handle user preferences for reduced motion.
- Centralized animation configurations in config.ts for easier management.
- Defined animation variants in variants.ts for consistent animation effects.
- Established AnimationProvider to supply global animation settings.
- Created tests for AnimationProvider and useReducedMotion hook.
- Added SVG assets for branding and UI elements.
- Documented frontend review plan and hero circuit board animation plan.
2026-03-15 21:06:43 -03:00

50 lines
1.6 KiB
TypeScript

import { renderHook } from "@testing-library/react";
import { useReducedMotion } from "./useReducedMotion";
// Mock do Framer Motion
jest.mock("framer-motion", () => ({
useReducedMotion: jest.fn(),
}));
describe("useReducedMotion", () => {
it("deve retornar false quando prefers-reduced-motion não está ativo", () => {
const { useReducedMotion: mockUseReducedMotion } =
jest.requireMock("framer-motion");
mockUseReducedMotion.mockReturnValue(false);
const { result } = renderHook(() => useReducedMotion());
expect(result.current).toBe(false);
});
it("deve retornar true quando prefers-reduced-motion está ativo", () => {
const { useReducedMotion: mockUseReducedMotion } =
jest.requireMock("framer-motion");
mockUseReducedMotion.mockReturnValue(true);
const { result } = renderHook(() => useReducedMotion());
expect(result.current).toBe(true);
});
it("deve retornar false quando o hook do Framer Motion retorna null", () => {
const { useReducedMotion: mockUseReducedMotion } =
jest.requireMock("framer-motion");
mockUseReducedMotion.mockReturnValue(null);
const { result } = renderHook(() => useReducedMotion());
expect(result.current).toBe(false);
});
it("deve retornar false quando o hook do Framer Motion retorna undefined", () => {
const { useReducedMotion: mockUseReducedMotion } =
jest.requireMock("framer-motion");
mockUseReducedMotion.mockReturnValue(undefined);
const { result } = renderHook(() => useReducedMotion());
expect(result.current).toBe(false);
});
});