MCPcopy
hub / github.com/tomkp/react-split-pane / createMockReactPointerEvent

Function createMockReactPointerEvent

src/hooks/useResizer.test.ts:34–60  ·  view source on GitHub ↗
(
  mockElement: HTMLDivElement,
  options: {
    clientX?: number;
    clientY?: number;
    pointerId?: number;
    pointerType?: string;
  } = {}
)

Source from the content-addressed store, hash-verified

32
33// Helper to create a mock React PointerEvent with nativeEvent
34function createMockReactPointerEvent(
35 mockElement: HTMLDivElement,
36 options: {
37 clientX?: number;
38 clientY?: number;
39 pointerId?: number;
40 pointerType?: string;
41 } = {}
42): React.PointerEvent {
43 const nativeEvent = new PointerEvent('pointerdown', {
44 clientX: options.clientX ?? 0,
45 clientY: options.clientY ?? 0,
46 pointerId: options.pointerId ?? 1,
47 pointerType: options.pointerType ?? 'mouse',
48 bubbles: true,
49 });
50
51 return {
52 preventDefault: vi.fn(),
53 clientX: options.clientX ?? 0,
54 clientY: options.clientY ?? 0,
55 pointerId: options.pointerId ?? 1,
56 pointerType: options.pointerType ?? 'mouse',
57 currentTarget: mockElement,
58 nativeEvent,
59 } as unknown as React.PointerEvent;
60}
61
62describe('useResizer', () => {
63 beforeEach(() => {

Callers 1

useResizer.test.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…