import { renderHook, act } from "@testing-library/react"; import { useCursor } from "./useCursor"; describe("useCursor", () => { test("should update the cursor position correctly", () => { const { result } = renderHook(() => useCursor()); act(() => { // Simulate a mouse event at position (100, 200) result.current.updateCursor({ currentTarget: { getBoundingClientRect: () => ({ left: 50, top: 100, }), }, clientX: 150, clientY: 300, } as React.MouseEvent); }); expect(result.current.position).toEqual({ x: 100, y: 200 }); }); test("should update the cursor position to null initially", () => { const { result } = renderHook(() => useCursor()); expect(result.current.position).toBeNull(); }); test("should set the position correctly using setPosition", () => { const { result } = renderHook(() => useCursor()); act(() => { result.current.setPosition({ x: 50, y: 100 }); }); expect(result.current.position).toEqual({ x: 50, y: 100 }); }); });